home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************
- ** **
- ** GuideML -- Converts AmigaGuide into HTML **
- ** **
- ***************************************************************/
- /*
- ** Copyright (C) 1997-98 Richard Körber -- All Rights Reserved
- ** E-Mail: shred@eratosthenes.starfleet.de
- ** URL: http://shredzone.home.pages.de
- **
- ** Updated 2001-2004 by Chris Young
- ** chris@unsatisfactorysoftware.co.uk
- ** http://www.unsatisfactorysoftware.co.uk
- ***************************************************************/
- /*
- ** This program is free software; you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation; either version 2 of the License, or
- ** any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program; if not, write to the Free Software
- ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- **
- ** The author (Richard Körber) reserves the right to revoke the
- ** GNU General Public License whenever he feels that it is necessary,
- ** especially when he found out that the licence has been abused,
- ** ignored or violated, and without prior notice.
- **
- ** You must not use this source code to gain profit of any kind!
- **
- ***************************************************************/
- /*
- ** If you use an editor that is capable of text folding, use
- ** "//>" and "//<" as begin and end fold markers, respectively.
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <clib/alib_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <pragmas/exec_pragmas.h>
- #include <pragmas/dos_pragmas.h>
- #include <exec/lists.h>
- #include <exec/nodes.h>
- #include <exec/memory.h>
- #include <dos/dos.h>
- #include <libraries/dos.h>
-
- #include <exec/types.h>
- #include <exec/io.h>
- #include <clib/asl_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/window_protos.h>
- #include <clib/layout_protos.h>
- #include <clib/checkbox_protos.h>
- #include <clib/button_protos.h>
- #include <clib/label_protos.h>
- #include <clib/chooser_protos.h>
- #include <clib/getfile_protos.h>
- #include <clib/clicktab_protos.h>
- #include <clib/string_protos.h>
- // #include <clib/integer_protos.h>
- // #include <clib/listbrowser_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/icon_protos.h>
-
- #include <intuition/intuition.h>
- #include <libraries/gadtools.h>
- #include <workbench/icon.h>
-
- #include <stdlib.h>
-
- #include <classes/window.h>
- #include <gadgets/layout.h>
- #include <gadgets/checkbox.h>
- #include <gadgets/button.h>
- #include <gadgets/chooser.h>
- #include <gadgets/clicktab.h>
- // #include <gadgets/integer.h>
- #include <gadgets/string.h>
- // #include <gadgets/listbrowser.h>
- #include <gadgets/getfile.h>
- #include <images/label.h>
-
- #include <reaction/reaction.h>
- #include <reaction/reaction_macros.h>
-
-
-
- #define VERSIONSTR "3.1" /* Version Nr */
- #define VERSIONDATE "03.01.2004" /* Version Date */
- #define LINELEN (1024) /* Maximum length of a line */
-
- extern struct Library *DOSBase;
- struct Library *aslbase;
- struct Library *intuitionbase;
- struct Library *WindowBase;
- struct Library *GadToolsBase;
- struct Library *LayoutBase;
- struct Library *ButtonBase;
- struct Library *CheckBoxBase;
- struct Library *LabelBase;
- struct Library *ChooserBase;
- struct Library *ClickTabBase;
- // struct Library *IntegerBase;
- struct Library *StringBase;
- // struct Library *ListBrowserBase;
- struct Library *GetFileBase;
- struct Library *IconBase;
-
- int err(char *,char *,int);
- void ui();
- void free_list(struct List *);
- void freetablist(struct List *);
- BOOL make_list(struct List *, UBYTE **);
- BOOL maketablist(struct List *, UBYTE **);
- void gettooltypes(); // struct WBArg *);
- struct Menu *addmenu(struct Window *);
- void cleanup(int);
-
- enum
- {
- GID_MAIN=0,
- GID_CONV,
- GID_FILE,
- GID_TO,
- GID_HOMEURL,
- GID_FINDURL,
- GID_PREV,
- GID_NEXT,
- GID_INDEX,
- GID_TOC,
- GID_HELP,
- GID_RETRACE,
- GID_HOME,
- GID_FIND,
- GID_BAR,
- GID_BODY,
- GID_LINKS,
- GID_MSDOS,
- GID_CSS,
- GID_HTMLHEADF,
- GID_HTMLFOOTF,
- GID_WRAP,
- GID_VARWIDTH,
- GID_NAVBAR,
- GID_MOZNAV,
- GID_IMAGES,
- GID_SHOWALL,
- GID_TABS,
- GID_PAGE,
- GID_LAST
- };
-
- enum
- {
- WID_MAIN=0,
- WID_LAST
- };
-
- enum
- {
- OID_MAIN=0,
- OID_LAST
- };
-
- struct Gadget *gadgets[GID_LAST];
-
- char VerStr[] = "\0$VER: GuideML "VERSIONSTR" ("VERSIONDATE")";
- static unsigned char defbar[] = " | ";
- // struct WBArg *wbarg;
-
-
- struct Parameter /* Structure of Shell parameters */
- {
- STRPTR from;
- STRPTR to;
- STRPTR homeurl;
- STRPTR findurl;
- STRPTR prev;
- STRPTR next;
- STRPTR index;
- STRPTR toc;
- STRPTR help;
- STRPTR retrace;
- STRPTR home;
- STRPTR find;
- STRPTR bar;
- STRPTR bodyext;
- LONG verbatim;
- LONG images;
- LONG footer;
- LONG nolink;
- LONG noemail;
- LONG nowarn;
- LONG msdos;
- LONG nonavbar;
- LONG nomoznav;
- LONG showall;
- STRPTR htmltoptxt;
- STRPTR htmlheadf;
- STRPTR htmlbottxt;
- STRPTR htmlfootf;
- STRPTR cssurl;
- LONG wordwrap;
- LONG smartwrap;
- LONG varwidth;
- LONG noauto;
- }param = {NULL};
-
- long *htmltop;
- long *htmlbot;
-
- struct text
- {
- STRPTR from;
- STRPTR to;
- STRPTR prev;
- STRPTR next;
- STRPTR index;
- STRPTR toc;
- STRPTR help;
- STRPTR retrace;
- STRPTR home;
- STRPTR find;
- STRPTR bar;
- };
-
- struct text textlabs;
-
- struct Entry /* List of all nodes and links */
- {
- struct MinNode link;
- ULONG Count;
- char Node[100];
- char Prev[100];
- char Next[100];
- char TOC[100];
- char Help[100];
- char Index[100];
- char Titl[100];
- };
- struct MinList entries;
-
- struct LinkStr /* Link bar alternative texts */
- {
- char Prev[100];
- char Next[100];
- char Index[100];
- char Toc[100];
- char Home[100];
- char Help[100];
- char Find[100];
- char Retrace[100];
- };
-
- char Index[100]; /* Index page name */
- char Help[100];
-
- //Some dummy memory-allocating rodents for tooltype porpoises.
- char *ttfrom = 0;
- char *ttto = 0;
- char *tthomeurl = 0;
- char *ttfindurl = 0;
- char *ttprev = 0;
- char *ttnext = 0;
- char *ttindex = 0;
- char *tttoc = 0;
- char *tthelp = 0;
- char *ttretrace = 0;
- char *tthome = 0;
- char *ttfind = 0;
- char *ttbar = 0;
- char *ttbody = 0;
- char *tthtmlheadf = 0;
- char *tthtmlfootf = 0;
- char *ttcss = 0;
-
- int wb=0;
- int ok=0;
-
- char defname[100];
-
- //> UBYTE Img#?[] = {...};
- /*
- ** These are the navigation bar images, in GIF format
- */
- UBYTE ImgHome[] =
- {
- 0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
- 0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
- 0x4A,0x08,0xBA,0x20,0xFC,0xB0,0x9D,0xD1,0x44,0x88,0x4B,0x9C,0x3D,0xF4,0xC5,0xDA,
- 0x26,0x1E,0x1F,0x14,0x8E,0x5B,0xC9,0x9C,0x28,0x69,0xB6,0x28,0x95,0x91,0x01,0x4B,
- 0x7B,0x73,0x70,0xD8,0x3A,0xAE,0x68,0x82,0x20,0x2A,0xE8,0x93,0xC0,0x50,0x25,0x4F,
- 0xED,0xC6,0x4C,0x92,0x76,0x4F,0x0F,0xD4,0x49,0x8C,0xEE,0x84,0xCE,0x51,0x0F,0x99,
- 0x09,0x78,0xBF,0xB4,0xAF,0x17,0x43,0x2E,0x9B,0x01,0x09,0x00,0x3B
-
- };
- #define LEN_IMGHOME (0x7C)
-
- UBYTE ImgIndex[] =
- {
- 0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
- 0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
- 0x41,0x28,0xBA,0xDC,0x12,0x40,0x9C,0x49,0xAB,0x85,0xD2,0x6A,0x8A,0x4F,0xF8,0x20,
- 0xE8,0x05,0x53,0xE7,0x2C,0x87,0x52,0x46,0x5B,0xDB,0x85,0xF0,0xB8,0x4A,0xA7,0xAA,
- 0x7A,0x6C,0xAB,0xBD,0xB0,0xF8,0xCD,0xA9,0x5A,0x10,0xA8,0xBB,0xB0,0x7A,0x3E,0x12,
- 0x8E,0x26,0xBC,0x75,0x8A,0x95,0x27,0x74,0x86,0xAC,0x42,0x00,0xD8,0xAC,0x76,0x9B,
- 0x4D,0x00,0x00,0x3B
-
-
- };
- #define LEN_IMGINDEX (0x73)
-
- UBYTE ImgNext[] =
- {
- 0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
- 0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
- 0x33,0x08,0xBA,0x2A,0xFC,0xB0,0x8D,0x48,0x81,0x38,0xB3,0xBE,0x8B,0x35,0xE3,0xDD,
- 0x27,0x8C,0xE4,0x78,0x9C,0x61,0x83,0xAE,0x6C,0x0A,0xB6,0x6C,0xA0,0xC2,0xF1,0x22,
- 0x04,0x78,0x8E,0xAF,0xB2,0x07,0xF6,0xBE,0x13,0x30,0x38,0xF4,0x15,0x7D,0x9E,0xA4,
- 0x72,0xA9,0x4C,0x00,0x00,0x3B
-
-
- };
- #define LEN_IMGNEXT (0x65)
-
- UBYTE ImgPrev[] =
- {
- 0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
- 0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
- 0x37,0x08,0xBA,0x10,0xFC,0x10,0x08,0x17,0xA3,0x38,0xB4,0xB2,0x8B,0xF5,0x3E,0x60,
- 0xA6,0x71,0xA0,0x60,0x9E,0xE7,0x42,0x82,0x6C,0xDB,0x01,0x83,0x2B,0xB3,0x59,0x3C,
- 0xBB,0xA2,0x1D,0x06,0x7C,0xCF,0x3F,0x3A,0x91,0xC7,0x26,0x1C,0xBE,0x3C,0x8C,0x41,
- 0x11,0xB9,0x44,0x3A,0x9F,0xD0,0x48,0x02,0x00,0x3B
-
-
- };
- #define LEN_IMGPREV (0x69)
-
- UBYTE ImgTOC[] =
- {
- 0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
- 0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
- 0x34,0x08,0xBA,0x20,0xFC,0xB0,0x9D,0x11,0xA3,0x38,0x98,0xD6,0x75,0x71,0xDE,0x92,
- 0xE7,0x69,0x50,0x27,0x8E,0xE5,0xA9,0x92,0x4D,0xE0,0xBA,0xDE,0xFB,0x56,0x66,0x00,
- 0x72,0xF1,0xAD,0xD4,0x7A,0x78,0xD8,0x3A,0x5E,0x30,0x37,0xC4,0x00,0x6F,0x02,0x59,
- 0x6F,0xC9,0x54,0x24,0x00,0x00,0x3B
- };
- #define LEN_IMGTOC (0x66)
-
- // below are temporary images
- UBYTE ImgHelp[] =
- {
- 0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
- 0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
- 0x36,0x08,0x2A,0xDC,0x32,0x2A,0x4A,0x71,0xAA,0xAD,0x50,0xAE,0xCB,0x4F,0xD0,0x00,
- 0x15,0x8C,0x24,0xE5,0x69,0xE6,0x37,0x55,0x6A,0x94,0xAE,0x27,0x28,0xB4,0x21,0x0B,
- 0xDE,0xEF,0x2D,0xC7,0x3A,0x4C,0xF7,0x0A,0x1E,0x70,0x08,0x64,0x10,0x5D,0xB6,0x63,
- 0xEE,0x38,0x3A,0x3A,0x9F,0x92,0x04,0x00,0x3B
-
- };
- #define LEN_IMGHELP (0x68)
-
- UBYTE ImgFind[] =
- {
- 0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
- 0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
- 0x42,0x08,0x0A,0xD2,0xBD,0x30,0x8A,0x43,0xE9,0x88,0x92,0x86,0x6D,0xB1,0x9A,0x47,
- 0xB0,0x0C,0x5D,0x16,0x46,0xE4,0x09,0x4D,0x22,0xC6,0x66,0x2D,0x2C,0xBB,0xEA,0x02,
- 0x5E,0xAB,0x86,0xA5,0x38,0xA3,0x7B,0x29,0x47,0xE5,0xD0,0x43,0x0D,0x43,0x95,0x22,
- 0x64,0xC3,0x04,0xA4,0x88,0x1E,0x60,0x32,0xBA,0xFB,0x51,0x21,0x83,0xCD,0x75,0xCB,
- 0x8D,0x24,0x00,0x00,0x3B
-
- };
- #define LEN_IMGFIND (0x74)
-
- UBYTE ImgRetrace[] =
- {
- 0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
- 0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
- 0x42,0x28,0x02,0xA0,0xCE,0x30,0x8A,0xA3,0x8E,0xB5,0x6A,0x44,0x36,0xAF,0xBF,0x9A,
- 0x74,0x05,0x24,0xE9,0x85,0xDC,0x18,0x0D,0xA0,0x54,0x92,0x6B,0xBB,0xCD,0xE9,0x11,
- 0xD0,0x74,0x77,0xE3,0x9B,0xCE,0xF7,0x96,0x5D,0x43,0x91,0x0B,0x8A,0x0E,0xA8,0x9A,
- 0xED,0x48,0x71,0x74,0x96,0x1B,0xD6,0x47,0x45,0x33,0x79,0x60,0xBF,0x97,0xF0,0xC7,
- 0xED,0xF2,0x12,0x00,0x3B
-
- };
- #define LEN_IMGRETRACE (0x74)
-
- //<
-
- //> STRPTR entity[96] = {...};
- /*
- ** This are the full names of all HTML entities
- */
- STRPTR entity[96] =
- {
- "nbsp","iexcl","cent","pound","curren","yen","brvbar","sect","uml",
- "copy","ordf","laquo","not","shy","reg","macr","deg","plusmn","sup2",
- "sup3","acute","micro","para","middot","cedil","sup1","ordm","raquo",
- "frac14","frac12","frac34","iquest","Agrave","Aacute","Acirc","Atilde",
- "Auml","Aring","AElig","Ccedil","Egrave","Eacute","Ecirc","Euml","Igrave",
- "Iacute","Icirc","Iuml","ETH","Ntilde","Ograve","Oacute","Ocirc","Otilde",
- "Ouml","times","Oslash","Ugrave","Uacute","Ucirc","Uuml","Yacute","THORN",
- "szlig","agrave","aacute","acirc","atilde","auml","aring","aelig","ccedil",
- "egrave","eacute","ecirc","euml","igrave","iacute","acirc","iuml","eth",
- "ntilde","ograve","oacute","ocirc","otilde","ouml","divide","oslash",
- "ugrave","uacute","ucirc","uuml","yacute","thorn","yuml"
- };
- //<
- //> STRPTR agpens[] , htmlpens[]
- /*
- ** This are the pen names in AmigaGuide documents
- */
- STRPTR agpens[] =
- {
- "text}","shine}","shadow}","fill}","filltext}","background}","highlight}",
- NULL
- };
-
- /*
- ** And this are the appropriate HTML colors
- */
- STRPTR htmlpens[] =
- {
- "#000000","#ffffff","#000000","#3864a0","#000000","#949494","#ffffff"
- };
-
- STRPTR cssclass[] =
- {
- "agtext","agshine","agshadow","agfill","agfilltext","agbackground","aghighlight"
- };
- //<
-
- //> SaveImg()
- /*------------------------------------------------------------*
- * SaveImg() Saves one image *
- * -> file File Name *
- * -> data Data buffer *
- * -> len Length *
- * <- Success *
- */
- LONG SaveImg(STRPTR file, UBYTE *data, ULONG len)
- {
- BPTR lock;
-
- if(lock = Lock(file,ACCESS_READ)) // Already existing?
- {
- UnLock(lock);
- return(1); // then leave with success
- }
-
- if(param.verbatim) Printf("Creating image '%s'\n",file); // Report
-
- if(lock = Open(file,MODE_NEWFILE)) // Open the image file
- {
- if(-1 == Write(lock,data,len)) // Write the image
- {
- Close(lock); // Write failed, so
- return(0); // return without success
- }
- Close(lock); // Write succeeded, so
- return(1); // return with success
- }
- return(0); // No lock, no success
- }
- //<
- //> SaveImages()
- /*------------------------------------------------------------*
- * SaveImages() Saves all required images *
- * <- Success *
- */
- LONG SaveImages(void)
- {
- for(;;)
- {
- if(param.homeurl)
- if(!SaveImg("home.gif" ,ImgHome ,LEN_IMGHOME )) break;
- if(param.retrace)
- if(!SaveImg("retrace.gif" ,ImgRetrace ,LEN_IMGRETRACE )) break;
- if(param.help)
- if(!SaveImg("help.gif" ,ImgHelp ,LEN_IMGHELP )) break;
- if(param.findurl)
- if(!SaveImg("find.gif" ,ImgFind ,LEN_IMGFIND )) break;
-
- // if(*Index)
- if(!SaveImg("index.gif",ImgIndex,LEN_IMGINDEX)) break;
-
- if(!SaveImg("next.gif" ,ImgNext ,LEN_IMGNEXT )) break;
- if(!SaveImg("prev.gif" ,ImgPrev ,LEN_IMGPREV )) break;
- if(!SaveImg("toc.gif" ,ImgTOC ,LEN_IMGTOC )) break;
- return(1);
- }
- return(0);
- }
- //<
-
- //> CopyLink()
- /*------------------------------------------------------------*
- * CopyLink() Copies a link file name into a variable *
- * -> link Link *
- * -> var String-Var *
- */
- void CopyLink(STRPTR link, STRPTR var)
- {
- char ch;
-
- var[0] = '\0'; // Init
-
- while(*link && *link==' ') link++; // Suppress spaces
- if(!*link) return; // there were only spaces!
-
- if(*link != '\"')
- { // Quick Mode
- while((ch = *link++)!=' ' && ch!='\n')
- {
- if(ch==':') ch='/'; // colon to slash again
- if(ch>='A' && ch<='Z') ch+=32; // upper to lower again
- *var++ = ch;
- }
- }
- else
- { // Quote Mode
- link++; // we had a leading quote
- if(!*link) return;
- while((ch = *link++)!='\"' && ch!='\n')
- {
- if(ch==' ') ch = '_'; // space converts to underscore
- if(ch==':') ch = '/'; // colon converts to slash
- if(ch>='A' && ch<='Z') ch+=32; // uppercase converts to lowercase
- *var++ = ch;
- }
- }
-
- *var++ = '.'; // Add html suffix
- *var++ = 'h';
- *var++ = 't';
- *var++ = 'm';
- if(!param.msdos) *var++ = 'l';
- *var = '\0';
- }
- //<
- //> MyPutCh()
- /*------------------------------------------------------------*
- * MyPutCh() Writes single chars into HTML *
- * -> fh output file handle *
- * -> ch Amiga char to be written *
- * <- -1 for failure *
- */
- LONG MyPutCh(BPTR fh, unsigned char ch)
- {
- if(ch<' ' && ch!='\n') // Is it a control char?
- {
- return FPrintf(fh,"%03ld;",ch); // yes: return them as number
- }
- else if(ch < 128) // Is it an ASCII char?
- {
- if(ch=='\"') return FPuts(fh,"""); // Convert some exceptions
- else if(ch=='&') return FPuts(fh,"&");
- else if(ch=='<') return FPuts(fh,"<"); // #060
- else if(ch=='>') return FPuts(fh,">"); // #062
- else return FPutC(fh,ch); // else put char directly
- }
- else // Chars >127 ?
- {
- if(ch>=160) // Do we have an entity name?
- return FPrintf(fh,"&%s;",entity[ch-160]); // yes: use this one
- else
- return FPrintf(fh,"%03ld;",ch); // no: use it's number
- }
- }
- //<
- //> MyPuts()
- /*------------------------------------------------------------*
- * MyPuts() Writes a string into HTML *
- * -> fh Output file handle *
- * -> str String to be output *
- * <- -1 for failure *
- */
- LONG MyPuts(BPTR fh, STRPTR str)
- {
- unsigned char ch;
-
- while(ch = *str++) // go through the string
- {
- if(ch=='\"' || ch=='<' || ch=='>' || ch=='&') // do NOT convert them
- { // since they are also used
- if(-1 == FPutC(fh,ch)) return(-1); // in HTML tags
- }
- else
- {
- if(-1 == MyPutCh(fh,ch)) return(-1);
- }
- }
- return(0);
- }
- //<
- //> ConvLine()
- /*------------------------------------------------------------*
- * ConvLine() Converts an AmigaGuide line *
- * -> fh output file handle *
- * -> buf Source buffer *
- * -> linenr line number *
- * <- Success *
- */
- LONG ConvLine(BPTR fh, STRPTR buf, ULONG linenr)
- {
- unsigned char ch;
- char linkstr[100];
- register UWORD dolink = !param.nolink;
- register UWORD doemail = !param.noemail;
-
- if((param.smartwrap) && (strlen(buf)<2))
- {
- if(-1 == FPuts(fh,"<br>")) return(0);
- }
-
- while(ch = *buf++) // while chars available
- {
- if('\\'==ch) // backslash escape character?
- {
- switch(*buf)
- {
- case '\\': // '\\' -> '\'
- case '@': // '\@' -> '@'
- if(-1 == MyPutCh(fh,*buf)) return(0);
- buf++;
- break;
- }
- continue;
- }
-
- if(doemail) // email recognition activated?
- {
- if( (ch>='a' && ch<='z') // Could this be a valid email?
- ||(ch>='A' && ch<='Z')
- ||(ch>='0' && ch<='9'))
- {
- UWORD length = 0; // length of the email string
- UWORD atfound = 0; // how many '@' were found?
- UWORD charcnt = 0; // how many characters in total?
- UWORD dotfound = 0; // how many dots?
- UWORD atdot = 0; // how many dots after the '@'?
- UWORD chardot = 0; // how many chars after the last dot?
- STRPTR index = --buf;
- UWORD i;
- unsigned char ech;
-
- while(ech = *index++)
- {
- if( !(ech>='a' && ech<='z') // still a valid email char?
- && !(ech>='A' && ech<='Z')
- && !(ech>='0' && ech<='9')
- && !(ech=='@' || ech=='.' || ech=='_' || ech=='-')) break;
- length++;
- if(ech=='@') // count '@'
- {
- if(*index=='{') // is it an AmigaGuide attribute?
- {
- length--; // exclude the '@'
- break; // the address is finished
- }
- atfound++;
- atdot = 0;
- continue;
- }
- if(ech=='.') // count '.'
- {
- dotfound++;
- atdot++;
- chardot = 0;
- continue;
- }
- charcnt++; // one more char
- chardot++;
- }
- if( atfound==1 // exactly one '@'
- && dotfound>0 // at least one '.' (domain.country)
- && atdot>0 // this dot must be after the '@'
- && chardot>=2 && chardot<=4 // domain must have two or three chars
- && charcnt>6) // and we have also some chars
- {
- if(-1 == FPuts(fh,"<a href=\"mailto:")) return(0); // Generate email link
- for(i=0;i<length;i++)
- {
- if(-1 == FPutC(fh,buf[i])) return(0);
- }
- if(-1 == FPuts(fh,"\">")) return(0);
- for(;length;length--)
- {
- if(-1 == FPutC(fh,*buf++)) return(0);
- }
- if(-1 == FPuts(fh,"</a>")) return(0);
- continue;
- }
- buf++;
- }
- }
-
- if(dolink) // internet link recognition
- {
- if( (!strnicmp(buf-1,"ftp://" ,6)) // ftp://... - Link ?
- ||(!strnicmp(buf-1,"gopher:" ,7)) // gopher:... - Link ?
- ||(!strnicmp(buf-1,"http://" ,7)) // http://... - Link ?
- ||(!strnicmp(buf-1,"https://",8)) // https://... - Link ?
- ||(!strnicmp(buf-1,"mailto:" ,7)) // mailto:... - Link ?
- ||(!strnicmp(buf-1,"news:" ,5)) // news:... - Link ?
- ||(!strnicmp(buf-1,"nntp:" ,5)) // nntp:... - Link ?
- ||(!strnicmp(buf-1,"telnet:" ,7)) // telnet:... - Link ?
- ||(!strnicmp(buf-1,"www." ,4))) // www. - Link?
- {
- STRPTR bufstart;
-
- if(-1 == FPuts(fh,"<a href=\"")) return(0);
-
- if(!strnicmp(buf-1,"www.",4))
- if(-1 == FPuts(fh,"http://")) return(0);
-
- bufstart = --buf;
- while(ch = *buf++)
- {
- if(' '==ch || '\n'==ch || ')'==ch || ('@'==ch && '{'==*buf)) break;
- if(-1 == FPutC(fh,ch)) return(0);
- }
- if(-1 == FPuts(fh,"\">")) return(0);
- for(;bufstart<buf-1;bufstart++) // followed by a verbatim copy
- {
- if(-1 == FPutC(fh,*bufstart)) return(0);
- }
- if(-1 == FPuts(fh,"</a>")) return(0);
- }
- }
-
- if('@'==ch && '{'==*buf) // AmigaGuide command?
- {
- buf++; // read the command?
- for(;;)
- {
- if('\"' == *buf) // is it a link?
- {
- STRPTR link;
- UWORD linkpos=0;
- BOOL linkquot=0;
-
- buf++; // skip the quotation marks
- link = buf;
- while(*link && *link!='\"') link++;
- if(!*link) return(0);
- link++;
- while(*link && (*link==' ' || *link==',' || *link=='\t')) link++;
- if(!*link) return(0);
- if(strnicmp(link,"link",4))
- { // this is NO link command!
- if(-1 == FPuts(fh,"<u>")) return(0);
- while((ch = *buf++) != '\"')
- if(-1 == MyPutCh(fh,ch)) return(0);
- if(-1 == FPuts(fh,"</u>")) return(0);
- buf = link;
- while(*buf && *buf!=' ') buf++;
- *buf++ = '\0';
- if(!param.nowarn) Printf("Line %ld: WARNING: '%s' command skipped!\n",linenr,link);
- while(*buf && *buf!='}') buf++;
- if(*buf =='}') buf++;
- break;
- }
- link+=4;
- while(*link && *link==' ') link++;
- if(!*link) return(0);
- if(*link == '\"')
- {
- link++;
- linkquot=1;
- }
- while(*link && *link!='}')
- {
- ch = *link++;
- if(ch=='\"' && linkquot) break;
- if(ch>='A' && ch<='Z') ch+=32;
- linkstr[linkpos++] = (ch==' ' || ch==':' ? '_' : ch);
- }
- while(*link && *link!='}') link++;
- while(linkpos>0 && linkstr[linkpos-1] == '_') linkpos--;
- if(linkstr[linkpos-1] == '\"') linkpos--;
- linkstr[linkpos] = '\0';
- if(!*link) return(0);
- link++;
- if(-1 == FPuts(fh,"<a href=\"")) return(0);
- if(-1 == FPuts(fh,linkstr)) return(0);
- if(param.msdos)
- {
- if(-1 == FPuts(fh,".htm\">")) return(0);
- }
- else
- {
- if(-1 == FPuts(fh,".html\">")) return(0);
- }
- while((ch = *buf++) != '\"')
- if(-1 == MyPutCh(fh,ch)) return(0);
- if(-1 == FPuts(fh,"</a>")) return(0);
- buf = link;
- break;
- }
-
- if(!strnicmp(buf,"b}",2)) // @{B}
- {
- if(-1 == FPuts(fh,"<b>")) return(0);
- buf += 2;
- break;
- }
- if(!strnicmp(buf,"ub}",3)) // @{UB}
- {
- if(-1 == FPuts(fh,"</b>")) return(0);
- buf += 3;
- break;
- }
-
- if(!strnicmp(buf,"i}",2)) // @{I}
- {
- if(-1 == FPuts(fh,"<i>")) return(0);
- buf += 2;
- break;
- }
- if(!strnicmp(buf,"ui}",3)) // @{UI}
- {
- if(-1 == FPuts(fh,"</i>")) return(0);
- buf += 3;
- break;
- }
-
- if(!strnicmp(buf,"u}",2)) // @{U}
- {
- if(-1 == FPuts(fh,"<u>")) return(0);
- buf += 2;
- break;
- }
- if(!strnicmp(buf,"uu}",3)) // @{UU}
- {
- if(-1 == FPuts(fh,"</u>")) return(0);
- buf += 3;
- break;
- }
- if(!strnicmp(buf,"code}",3)) // @{CODE}
- {
- if(-1 == FPuts(fh,"<pre>")) return(0);
- buf += 5;
- break;
- }
- if(!strnicmp(buf,"body}",3)) // @{BODY}
- {
- if(-1 == FPuts(fh,"</pre>")) return(0);
- buf += 5;
- break;
- }
- if(!strnicmp(buf,"line}",3)) // @{LINE}
- {
- if(-1 == FPuts(fh,"<br>")) return(0);
- buf += 5;
- break;
- }
- if(!strnicmp(buf,"par}",3)) // @{PAR}
- {
- if(-1 == FPuts(fh,"<p>")) return(0);
- buf += 4;
- break;
- }
- if(!strnicmp(buf,"plain}",3)) // @{PLAIN}
- {
- if(-1 == FPuts(fh,"</b></i></u>")) return(0);
- buf += 6;
- break;
- }
-
- if(!strnicmp(buf,"fg ",3)) // @{FG ...}
- {
- UWORD i=0;
- buf += 3;
-
- while(*buf == ' ') buf++;
-
- while(agpens[i])
- {
- if(!strnicmp(buf,agpens[i],strlen(agpens[i])))
- {
- if(-1 == FPrintf(fh,"<font color=\"%s\" class=\"%s\">",htmlpens[i],cssclass[i])) return(0);
- buf += strlen(agpens[i]);
- break;
- }
- i++;
- }
- if(agpens[i]) break;
- }
-
- while(*buf && *buf!='}') buf++; // Skip an unknown command!
- buf++;
- break;
- }
-
- }
- else
- if(-1 == MyPutCh(fh,ch)) return(0); // Error!
- }
- return(1);
- }
- //<
-
- //> NavBar()
- /*------------------------------------------------------------*
- * NavBar() Produces the navigation bar *
- * -> tfh output file handle *
- * -> enode node with link data *
- * <- Success *
- */
- LONG NavBar(BPTR tfh, struct Entry *enode)
- {
- short before = 0;
-
- for(;;)
- {
-
- if(param.homeurl)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",param.homeurl)) break;
- if(-1 == MyPuts(tfh,param.home)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
-
-
- if(enode->Count) // main page does not have a TOC link
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
-
- if(param.msdos)
- {
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",(*enode->TOC ? enode->TOC : "main.htm"))) break;
- }
- else
- {
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",(*enode->TOC ? enode->TOC : "main.html"))) break;
- }
- if(-1 == MyPuts(tfh,param.toc)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
- else if(param.showall)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == MyPuts(tfh,param.toc)) break;
- before = 1;
- }
-
- if(*enode->Index)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",enode->Index)) break;
- if(-1 == MyPuts(tfh,param.index)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
- else if(*Index)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",Index)) break;
- if(-1 == MyPuts(tfh,param.index)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
- else if(param.showall)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == MyPuts(tfh,param.index)) break;
- before = 1;
- }
-
- if(*enode->Help)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",enode->Help)) break;
- if(-1 == MyPuts(tfh,param.help)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
- else if(*Help)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",Help)) break;
- if(-1 == MyPuts(tfh,param.help)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
- else if(param.showall)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"http://www.unsatisfactorysoftware.co.uk/guideml/help.guide/main.html\">",Help)) break;
- if(-1 == MyPuts(tfh,param.help)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
-
- if(param.retrace)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == MyPuts(tfh,"<a href=\"javascript:window.history.go(-1)\">")) break;
- if(-1 == MyPuts(tfh,param.retrace)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
-
- if(*enode->Prev)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",enode->Prev)) break;
- if(-1 == MyPuts(tfh,param.prev)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
- else
- {
- struct Entry *pred = (struct Entry *)enode->link.mln_Pred;
- if(pred->link.mln_Pred)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",pred->Node)) break;
- if(-1 == MyPuts(tfh,param.prev)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
- else if(param.showall)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == MyPuts(tfh,param.prev)) break;
- before = 1;
- }
-
- }
-
- if(*enode->Next)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",enode->Next)) break;
- if(-1 == MyPuts(tfh,param.next)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
- else
- {
- struct Entry *next = (struct Entry *)enode->link.mln_Succ;
- if(next->link.mln_Succ)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",next->Node)) break;
- if(-1 == MyPuts(tfh,param.next)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
- else if(param.showall)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == MyPuts(tfh,param.next)) break;
- before = 1;
- }
-
- }
- if(param.findurl)
- {
- if(before) if(-1 == MyPuts(tfh,param.bar)) break;
- if(-1 == FPrintf(tfh,"<a href=\"%s\">",param.findurl)) break;
- if(-1 == MyPuts(tfh,param.find)) break;
- if(-1 == FPuts(tfh,"</a>")) break;
- before = 1;
- }
-
-
- if(-1 == FPutC(tfh,'\n')) break;
- return(1); // ALL OK
- }
- return(0); // ERROR
- }
- //<
-
- //> MozNavBar()
- /*--------------------------------------------------------------------*
- * MozNavBar() Produces a Mozilla-compatible site navigation bar *
- * -> tfh output file handle *
- * -> enode node with link data *
- * <- Success *
- */
- LONG MozNavBar(BPTR tfh, struct Entry *enode)
- {
- short before = 0;
-
- for(;;)
- {
- if(enode->Count) // main page does not have a TOC link
- {
- if(param.msdos)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"up\" href=\"%s\" title=\"%s\" />\n",(*enode->TOC ? enode->TOC : "main.htm"),textlabs.toc)) break;
- }
- else
- {
- if(-1 == FPrintf(tfh,"<link rel=\"up\" href=\"%s\" title=\"%s\" />\n",(*enode->TOC ? enode->TOC : "main.html"),textlabs.toc)) break;
- }
- }
-
- if(*enode->Index)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"index\" href=\"%s\" title=\"%s\" />\n",enode->Index,textlabs.index)) break;
- }
- else if(*Index)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"index\" href=\"%s\" title=\"%s\" />\n",Index,param.index)) break;
- }
-
- if(*enode->Prev)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"previous\" href=\"%s\" title=\"%s\" />\n",enode->Prev,textlabs.prev)) break;
- }
- else
- {
- struct Entry *pred = (struct Entry *)enode->link.mln_Pred;
- if(pred->link.mln_Pred)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"previous\" href=\"%s\" title=\"%s\" />\n",pred->Node,textlabs.prev)) break;
- }
- }
-
- if(*enode->Next)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"next\" href=\"%s\" title=\"%s\" />\n",enode->Next,textlabs.next)) break;
- }
- else
- {
- struct Entry *next = (struct Entry *)enode->link.mln_Succ;
- if(next->link.mln_Succ)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"next\" href=\"%s\" title=\"%s\" />\n",next->Node,textlabs.next)) break;
- }
- }
-
- if(*enode->Help)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"help\" href=\"%s\" title=\"%s\" />\n",enode->Help,textlabs.help)) break;
- }
- else if(*Help)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"help\" href=\"%s\" title=\"%s\" />\n",Help,textlabs.help)) break;
- }
- else
- {
- if(-1 == FPuts(tfh,"<link rel=\"help\" href=\"http://www.unsatisfactorysoftware.co.uk/guideml/help.guide/main.html\" title=\"AmigaGuide Help\" />\n")) break;
- }
-
- if(param.homeurl)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"top\" href=\"%s\" title=\"%s\" />\n",param.homeurl,textlabs.home)) break;
- }
-
- if(param.findurl)
- {
- if(-1 == FPrintf(tfh,"<link rel=\"search\" href=\"%s\" title=\"%s\" />\n",param.findurl,textlabs.find)) break;
- }
-
- if(-1 == FPuts(tfh,"<link rel=\"GuideML\" href=\"http://www.unsatisfactorysoftware.co.uk/\" title=\"Unsatisfactory Software\" />\n")) break;
-
-
- // if(-1 == FPutC(tfh,'\n')) break;
- return(1); // ALL OK
- }
- return(0); // ERROR
- }
- //<
-
- //> Convert()
- /*------------------------------------------------------------*
- * Convert() Reads guide and creates HTML files *
- * -> fh input file handle *
- * <- Success *
- */
- LONG Convert(BPTR fh)
- {
- STRPTR buffer = AllocVec(LINELEN,MEMF_ANY); // allocate line buffer
- char copyright[100] = "\0";
- char author[100] = "\0";
- char version[100] = "\0";
- char master[100] = "\0";
- char database[100] = "\0";
- char keywords[100] = "\0";
- char description[200] = "\0";
- STRPTR node, title, line;
- char nodename[100];
- BPTR tfh = NULL;
- ULONG linenr = 0;
- short firstpage = 1;
- struct Entry *enode = (struct Entry *)entries.mlh_Head;
- register UWORD donavbar = !param.nonavbar;
- LONG wrap = 0;
-
- if(param.wordwrap || param.smartwrap) wrap = 1;
-
- if(!buffer) return(0);
-
- PutStr("Converting into HTML\n");
-
- /* search for @node */
- do
- {
- linenr++;
- if(FGets(fh,buffer,LINELEN) == NULL) goto Done;
-
- if(!param.noauto)
- {
- if(strnicmp(buffer,"@wordwrap",9)==0)
- {
- PutStr("@wordwrap detected!\n");
- param.wordwrap = 1;
- wrap = 1;
- }
- if(strnicmp(buffer,"@smartwrap",10)==0)
- {
- PutStr("@smartwrap detected!\n");
- param.smartwrap = 1;
- wrap = 1;
- }
- }
-
- // the below would be seriously better off as subroutines...
-
- if(strnicmp(buffer,"@(c) ",5)==0)
- {
- line = buffer+5;
- while(*line == ' ') line++; // Skip spaces
- if(*line == '\"') line++; // Skip quotation mark
- title = line;
- while(*line != '\n') line++; // search EOL
- do line--; while(*line==' '); // skip trailing spaces
- if(*line == '\"') line--; // skip trailing quotation mark
- *++line = '\0'; // terminate the line
- strcpy(copyright,title);
- }
-
- if(strnicmp(buffer,"@author ",8)==0)
- {
- line = buffer+8;
- while(*line == ' ') line++; // Skip spaces
- if(*line == '\"') line++; // Skip quotation mark
- title = line;
- while(*line != '\n') line++; // search EOL
- do line--; while(*line==' '); // skip trailing spaces
- if(*line == '\"') line--; // skip trailing quotation mark
- *++line = '\0'; // terminate the line
- strcpy(author,title);
- }
-
- if(strnicmp(buffer,"@$ver:",6)==0)
- {
- line = buffer+6;
- while(*line == ' ') line++; // Skip spaces
- if(*line == '\"') line++; // Skip quotation mark
- title = line;
- while(*line != '\n') line++; // search EOL
- do line--; while(*line==' '); // skip trailing spaces
- if(*line == '\"') line--; // skip trailing quotation mark
- *++line = '\0'; // terminate the line
- strcpy(version,title);
- }
-
- if(strnicmp(buffer,"@database ",10)==0)
- {
- line = buffer+10;
- while(*line == ' ') line++; // Skip spaces
- if(*line == '\"') line++; // Skip quotation mark
- title = line;
- while(*line != '\n') line++; // search EOL
- do line--; while(*line==' '); // skip trailing spaces
- if(*line == '\"') line--; // skip trailing quotation mark
- *++line = '\0'; // terminate the line
- strcpy(database,title);
- }
-
- if(strnicmp(buffer,"@master ",8)==0)
- {
- line = buffer+8;
- while(*line == ' ') line++; // Skip spaces
- if(*line == '\"') line++; // Skip quotation mark
- title = line;
- while(*line != '\n') line++; // search EOL
- do line--; while(*line==' '); // skip trailing spaces
- if(*line == '\"') line--; // skip trailing quotation mark
- *++line = '\0'; // terminate the line
- strcpy(master,title);
- }
-
- if(strnicmp(buffer,"@keywords ",10)==0)
- {
- line = buffer+10;
- while(*line == ' ') line++; // Skip spaces
- if(*line == '\"') line++; // Skip quotation mark
- title = line;
- while(*line != '\n') line++; // search EOL
- do line--; while(*line==' '); // skip trailing spaces
- if(*line == '\"') line--; // skip trailing quotation mark
- *++line = '\0'; // terminate the line
- strcpy(keywords,title);
- }
-
- if(strnicmp(buffer,"@description ",13)==0)
- {
- line = buffer+13;
- while(*line == ' ') line++; // Skip spaces
- if(*line == '\"') line++; // Skip quotation mark
- title = line;
- while(*line != '\n') line++; // search EOL
- do line--; while(*line==' '); // skip trailing spaces
- if(*line == '\"') line--; // skip trailing quotation mark
- *++line = '\0'; // terminate the line
- strcpy(description,title);
- }
-
- }
- while(strnicmp(buffer,"@node ",strlen("@node ")));
-
- /* and go... */
- for(;;)
- {
- if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) goto ErrorBrk;
-
- /* search the node name */
- node = buffer+strlen("@node ");
- while(*node == ' ') node++; // skip leading spaces
- if(*node == '\"')
- { // Quote Mode
- node++;
- line = node;
- while(*line!='\"' && *line!='\n')
- {
- if(*line==' ' || *line==':') *line='_'; // space -> '_'
- line++;
- }
- *line++ = '\0';
- }
- else
- {
- line = node;
- while(*line!=' ' && *line!='\n')
- {
- if(*line==':') *line='/'; // ':' -> '_'
- line++;
- }
- *line++ = '\0';
- }
-
- /* search node title */
- if(*line == '\0')
- {
- title = line; // Node does not have a title
- if(*enode->Titl)
- {
- title = enode->Titl;
- }
- }
- else
- {
- while(*line == ' ') line++; // Skip spaces
- if(*line == '\"') line++; // Skip quotation mark
- title = line;
- while(*line != '\n') line++; // search EOL
- do line--; while(*line==' '); // skip trailing spaces
- if(*line == '\"') line--; // skip trailing quotation mark
- *++line = '\0'; // terminate the line
- }
-
- strlwr(node); // node name to lowercase
- strcpy(nodename,node);
- if(param.msdos)
- {
- strcat(nodename,".htm");
- }
- else
- {
- strcat(nodename,".html");
- }
-
- if(tfh = Open(nodename,MODE_NEWFILE))
- {
- if(param.verbatim) Printf("Creating page '%s' (Title: '%s')\n",nodename,title);
- if(-1 == FPuts(tfh,"<html>\n<head>\n<title>")) goto ErrorFile;
- if(-1 == MyPuts(tfh,title)) goto ErrorFile;
- if(-1 == FPuts(tfh,"</title>\n"
- "<meta name=\"Generator\" content=\"GuideML " VERSIONSTR " (http://www.unsatisfactorysoftware.co.uk/guideml/)\">\n"
- "<meta http-equiv=\"Content-Type\" content=\"text/html\">\n")) goto ErrorFile;
- // start custom meta
- if(strlen(copyright) > 2)
- {
- if(-1 == FPuts(tfh,"<meta name=\"Copyright\" content=\"")) goto ErrorFile;
- if(-1 == MyPuts(tfh,copyright)) goto ErrorFile;
- if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
- }
- // end custom meta
- // start custom meta
- if(strlen(author) > 2)
- {
- if(-1 == FPuts(tfh,"<meta name=\"Author\" content=\"")) goto ErrorFile;
- if(-1 == MyPuts(tfh,author)) goto ErrorFile;
- if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
- }
- // end custom meta
- // start custom meta
- if(strlen(version) > 2)
- {
- if(-1 == FPuts(tfh,"<meta name=\"Version\" content=\"")) goto ErrorFile;
- if(-1 == MyPuts(tfh,version)) goto ErrorFile;
- if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
- }
- // end custom meta
- // start custom meta
- if(strlen(database) > 2)
- {
- if(-1 == FPuts(tfh,"<meta name=\"Database\" content=\"")) goto ErrorFile;
- if(-1 == MyPuts(tfh,database)) goto ErrorFile;
- if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
- }
- // end custom meta
- // start custom meta
- if(strlen(master) > 2)
- {
- if(-1 == FPuts(tfh,"<meta name=\"Master\" content=\"")) goto ErrorFile;
- if(-1 == MyPuts(tfh,master)) goto ErrorFile;
- if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
- }
- // end custom meta
- // start custom meta
- if(strlen(keywords) > 2)
- {
- if(-1 == FPuts(tfh,"<meta name=\"Keywords\" content=\"")) goto ErrorFile;
- if(-1 == MyPuts(tfh,keywords)) goto ErrorFile;
- if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
- }
- // end custom meta
- // start custom meta
- if(strlen(description) > 2)
- {
- if(-1 == FPuts(tfh,"<meta name=\"Description\" content=\"")) goto ErrorFile;
- if(-1 == MyPuts(tfh,description)) goto ErrorFile;
- if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
- }
- // end custom meta
-
- if(param.cssurl)
- {
- if(-1 == FPuts(tfh,"<link rel=\"stylesheet\" href=\"")) goto ErrorFile;
- if(-1 == MyPuts(tfh,param.cssurl)) goto ErrorFile;
- if(-1 == FPuts(tfh,"\" type=\"text/css\">")) goto ErrorFile;
- }
-
- if(!param.nomoznav)
- {
- if(!MozNavBar(tfh,enode)) goto ErrorFile;
- }
-
-
- if(-1 == FPuts(tfh,"</head>\n<body")) goto ErrorFile;
-
- if(param.bodyext)
- {
- if(-1 == FPutC(tfh,' ')) goto ErrorFile;
- if(-1 == MyPuts(tfh,param.bodyext)) goto ErrorFile;
- }
- if(-1 == FPuts(tfh,">\n")) goto ErrorFile;
-
- if(param.htmltoptxt)
- {
- if(-1 == FPutC(tfh,' ')) goto ErrorFile;
- if(-1 == MyPuts(tfh,param.htmltoptxt)) goto ErrorFile;
- }
- if(param.htmlheadf)
- {
- if(-1 == FPutC(tfh,' ')) goto ErrorFile;
- if(-1 == MyPuts(tfh,(STRPTR)htmltop)) goto ErrorFile;
- }
-
-
- if(donavbar)
- {
- if(!NavBar(tfh,enode)) goto ErrorFile;
- if(-1 == FPuts(tfh,"<hr>\n")) goto ErrorFile;
- }
-
- if(!wrap)
- {
- if(-1 == FPuts(tfh,"<pre>\n")) goto ErrorFile;
- }
- else
- {
- if(!param.varwidth)
- {
- if(-1 == FPuts(tfh,"<tt>\n")) goto ErrorFile;
- }
- }
-
- for(;;)
- {
- linenr++;
- if(FGets(fh,buffer,LINELEN) == NULL) goto ErrorEOF;
-
- // TEMPORARY FOR TEST PORPOISES!
- //Printf("%s\n",buffer);
-
- if(buffer[0]=='@' && buffer[1]!='{') // is it an AmigaGuide command
- {
- if(!strnicmp(buffer,"@node ",strlen("@node "))) break;
- if(!strnicmp(buffer,"@endnode",strlen("@endnode"))) break;
- continue; // unknown command
- }
-
- if(!ConvLine(tfh,buffer,linenr))
- {
- Printf("Line %ld: Couldn't convert!\n",linenr);
- goto Error;
- }
- if(param.wordwrap)
- {
- if(-1 == FPuts(tfh,"<br>")) return(0);
- }
-
- }
-
- if(!wrap)
- {
- if(-1 == FPuts(tfh,"</pre>\n")) goto ErrorFile;
- }
- else
- {
- if(!param.varwidth)
- {
- if(-1 == FPuts(tfh,"</tt>\n")) goto ErrorFile;
- }
- }
-
- if(param.footer)
- {
- if(-1 == FPuts(tfh,"<hr>\n")) goto ErrorFile;
- if(donavbar)
- {
- if(!NavBar(tfh,enode)) goto ErrorFile;
- }
- }
-
- if(param.htmlbottxt)
- {
- if(-1 == FPutC(tfh,' ')) goto ErrorFile;
- if(-1 == MyPuts(tfh,param.htmlbottxt)) goto ErrorFile;
- }
- else if(param.htmlfootf)
- {
- if(-1 == FPutC(tfh,' ')) goto ErrorFile;
- if(-1 == MyPuts(tfh,(STRPTR)htmlbot)) goto ErrorFile;
- }
- else
- {
- if(firstpage)
- {
- firstpage = 0;
- if(-1 == FPuts(tfh,"<hr>\n<address>Converted using <a href=\"http://www.unsatisfactorysoftware.co.uk/guideml/\">GuideML "VERSIONSTR "</a></address>\n")) goto ErrorFile;
- }
- }
-
-
- if(-1 == FPuts(tfh,"</body>\n</html>\n")) goto ErrorFile;
- enode = (struct Entry *)enode->link.mln_Succ;
- Close(tfh);
- tfh = NULL;
- }
- else
- {
- Printf("Line %ld: Couldn't open %s for writing!\n",linenr,nodename);
- goto Error;
- }
-
- while(strnicmp(buffer,"@node ",strlen("@node ")))
- {
- linenr++;
- if(FGets(fh,buffer,LINELEN) == NULL) goto Done;
- }
- }
-
- Done:
- FreeVec(buffer);
- return(1);
-
- ErrorBrk:
- Printf("Line %ld: <CTRL-C> pressed!\n",linenr);
- goto Error;
- ErrorFile:
- Printf("Line %ld: Error writing file!\n",linenr);
- goto Error;
- ErrorEOF:
- Printf("Line %ld: Unexpected EOF!\n",linenr);
- Error:
- if(tfh) Close(tfh);
- FreeVec(buffer);
- return(0);
- }
- //<
- //> PreScan()
- /*------------------------------------------------------------*
- * PreScan() Scans the AmigaGuide file *
- * -> fh input file handle *
- * <- Success *
- */
- LONG PreScan(BPTR fh)
- {
- STRPTR buffer = AllocVec(LINELEN,MEMF_ANY); // allocate line buffer
- STRPTR parse;
- ULONG linenr = 0;
- ULONG nodectr = 0;
- struct Entry *currentry = NULL;
-
- if(!buffer) return(0);
-
- PutStr("Scanning AmigaGuide document\n");
- /* Is it an AmigaGuide document ? */
- linenr++;
- if(NULL == FGets(fh,buffer,LINELEN)) goto ErrorEOF;
- if(strnicmp(buffer,"@database",strlen("@database")))
- {
- PutStr("This is no valid AmigaGuide file!\n");
- goto Error;
- }
-
- /* Search for commands */
- for(;;)
- {
- if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) goto ErrorBrk;
- linenr++;
- if(!FGets(fh,buffer,LINELEN)) break; // Scan all lines
- if(buffer[0]!='@') continue; // no command line
- if(buffer[1]=='{') continue; // a text command at first column?
-
- parse = buffer+1;
-
- if(!strnicmp(parse,"node ",strlen("node "))) // @node <name>
- {
- if(currentry) AddTail((struct List *)&entries,(struct Node *)currentry);
- currentry = AllocVec(sizeof(struct Entry),MEMF_ANY|MEMF_CLEAR);
- if(!currentry) goto ErrorMem;
- currentry->Count = nodectr++;
- CopyLink(parse+strlen("node "), currentry->Node);
- }
-
- if(!strnicmp(parse,"index ",strlen("index "))) // @index <index>
- {
- if(currentry)
- {
- CopyLink(parse+strlen("prev "), currentry->Index);
- }
- else
- {
- CopyLink(parse+strlen("index "), Index);
- }
- }
-
- if(!strnicmp(parse,"prev ",strlen("prev "))) // @prev <name>
- {
- if(currentry)
- {
- CopyLink(parse+strlen("prev "), currentry->Prev);
- }
- }
-
- if(!strnicmp(parse,"next ",strlen("next "))) // @next <name>
- {
- if(currentry)
- {
- CopyLink(parse+strlen("next "), currentry->Next);
- }
- }
-
- if(!strnicmp(parse,"toc ",strlen("toc "))) // @toc <name>
- {
- if(currentry)
- {
- CopyLink(parse+strlen("toc "), currentry->TOC);
- }
- }
-
- if(!strnicmp(parse,"title ",strlen("title "))) // @title <name>
- {
- if(currentry)
- {
- CopyLink(parse+strlen("title "), currentry->Titl);
- }
- }
-
- if(!strnicmp(parse,"help ",strlen("help "))) // @help <name>
- {
- if(currentry)
- {
- CopyLink(parse+strlen("help "), currentry->Help);
- }
- else
- {
- CopyLink(parse+strlen("help "), Help);
- }
- }
-
- if(!strnicmp(parse,"endnode",strlen("endnode"))) // @endnode
- {
- if(currentry)
- {
- AddTail((struct List *)&entries,(struct Node *)currentry);
- currentry = NULL;
- }
- }
- }
- if(currentry)
- {
- AddTail((struct List *)&entries,(struct Node *)currentry);
- if(!param.nowarn) Printf("Line %ld: WARNING: No closing @endnode found!\n",linenr);
- //* currentry = NULL;
- }
-
- FreeVec(buffer);
- return(1);
-
- ErrorMem:
- Printf("Line %ld: Not enough memory!\n",linenr);
- goto Error;
- ErrorBrk:
- Printf("Line %ld: <CTRL-C> pressed!\n",linenr);
- goto Error;
- ErrorEOF:
- Printf("Line %ld: Unexpected EOF!\n",linenr);
- Error:
- FreeVec(buffer);
- return(0);
- }
- //<
-
- //> main()
- /*------------------------------------------------------------*
- * main() M A I N P R O G R A M *
- */
- int main(void)
- {
- struct RDArgs *args;
- static char template[] = "FILE/A,TO/K,URL=HOMEURL/K,FINDURL=SEARCHURL/K,PREV/K,NEXT/K,INDEX/K,TOC/K,HELP/K,RETRACE/K,HOME/K,FIND=SEARCH/K,BAR/K,BODY/K,VER=VERBATIM/S,IMG=IMAGES/S,FTR=FOOTER/S,NL=NOLINKS/S,NE=NOEMAIL/S,NW=NOWARN/S,MSDOS/S,NONAVBAR/S,NOMOZNAV/S,SHOWALL/S,HTMLHEAD/K,HTMLHEADF/K,HTMLFOOT/K,HTMLFOOTF/K,CSS/K,WORDWRAP/S,SMARTWRAP/S,VARWIDTH/S,NOAUTO/S";
- BPTR fh;
- BPTR hhf;
- BPTR oldlock = NULL;
- struct Entry *node, *next;
- struct LinkStr *lstr = NULL;
- struct FileInfoBlock *fib = NULL;
- long hfs = 4096;
- long hhs = 4096;
-
- NewList((struct List *)&entries);
-
-
- if(!wb)
- {
- param.prev = "< Browse";
- param.next = "Browse >";
- param.index = "Index";
- param.toc = "Contents";
- param.home = "Home";
- param.help = "Help";
- param.find = "Search";
- param.bar = defbar;
- param.retrace = NULL;
-
- if(args = (struct RDArgs *)ReadArgs(template,(LONG *)¶m,NULL))
- {
- ok=1;
- }
- }
-
- if(ok)
- {
- PutStr("GuideML "VERSIONSTR"\n");
-
- textlabs.prev = param.prev;
- textlabs.next = param.next;
- textlabs.index = param.index;
- textlabs.toc = param.toc;
- textlabs.home = param.home;
- textlabs.help = param.help;
- textlabs.find = param.find;
- textlabs.retrace = param.retrace;
- textlabs.bar = param.bar;
-
- if(param.images)
- {
- lstr = AllocVec(sizeof(struct LinkStr),MEMF_ANY);
- if(!lstr)
- {
- PutStr("**ERROR: Out of memory.\n");
- goto Flush;
- }
-
- sprintf(lstr->Prev ,"<img src=\"prev.gif\" alt=\"%s\" border=0>" ,param.prev );
- sprintf(lstr->Next ,"<img src=\"next.gif\" alt=\"%s\" border=0>" ,param.next );
- sprintf(lstr->Index,"<img src=\"index.gif\" alt=\"%s\" border=0>",param.index);
- sprintf(lstr->Retrace,"<img src=\"retrace.gif\" alt=\"%s\" border=0>",param.retrace);
- sprintf(lstr->Toc ,"<img src=\"toc.gif\" alt=\"%s\" border=0>" ,param.toc );
- sprintf(lstr->Home ,"<img src=\"home.gif\" alt=\"%s\" border=0>" ,param.home );
- sprintf(lstr->Help ,"<img src=\"help.gif\" alt=\"%s\" border=0>" ,param.help );
- sprintf(lstr->Find ,"<img src=\"find.gif\" alt=\"%s\" border=0>" ,param.find );
- param.prev = lstr->Prev;
- param.next = lstr->Next;
- param.index = lstr->Index;
- param.toc = lstr->Toc;
- param.home = lstr->Home;
- param.help = lstr->Help;
- param.find = lstr->Find;
- if(param.retrace) param.retrace = lstr->Retrace;
- if(param.bar == defbar) param.bar = "";
- }
-
-
- if(param.htmlheadf)
- {
- if(hhf=Open(param.htmlheadf,MODE_OLDFILE))
- {
- // if(ExamineFH(hhf,fib))
- // {
- // hhs=fib->fib_Size;
- if(htmltop = AllocMem(hhs,MEMF_CLEAR))
- {
- Read(hhf,htmltop,hhs);
-
- param.htmltoptxt=NULL;
- printf("%s loaded ok\n",param.htmlheadf);
-
- }
- Close(hhf);
- }
- }
-
- if(param.htmlfootf)
- {
- if(hhf=Open(param.htmlfootf,MODE_OLDFILE))
- {
- if(htmlbot = AllocMem(hfs,MEMF_CLEAR))
- {
- Read(hhf,htmlbot,hfs);
- param.htmlbottxt=NULL;
- printf("%s loaded ok\n",param.htmlfootf);
- }
- Close(hhf);
- }
- }
-
- if(fh = Open(param.from,MODE_OLDFILE))
- {
- if(param.to)
- {
- BPTR destlock;
- destlock = Lock(param.to,ACCESS_READ);
- if(!destlock)
- {
- PutStr("**ERROR: Couldn't lock destination drawer.\n");
- Close(fh);
- goto Flush;
- }
- oldlock = CurrentDir(destlock);
- }
-
- if(!PreScan(fh))
- {
- PutStr("**ERROR: Scanning failed.\n");
- Close(fh);
- goto Flush;
- }
- Seek(fh,0,OFFSET_BEGINNING);
- if(!Convert(fh))
- {
- PutStr("**ERROR: Conversion failed.\n");
- Close(fh);
- goto Flush;
- }
- Close(fh);
- }
- else
- Printf("**ERROR: couldn't open file %s!\n",param.from);
-
- if(param.images)
- {
- PutStr("Saving images\n");
- if(!SaveImages())
- PutStr("**ERROR: couldn't save image files\n");
- }
-
- Printf("All finished!\n");
-
- Flush:
- for (node = (struct Entry *)entries.mlh_Head;
- next = (struct Entry *)node->link.mln_Succ;
- node = next)
- {
- Remove((struct Node *)node);
- FreeVec(node);
- }
-
- if(lstr) FreeVec(lstr);
- if(htmltop) FreeMem(htmltop,hhs);
- if(htmlbot) FreeMem(htmlbot,hfs);
-
-
- if(oldlock) UnLock(CurrentDir(oldlock));
-
- if(!wb) FreeArgs(args);
- }
- else
- PutStr("GuideML "VERSIONSTR"\n"
- "© 1997-98 by Richard Körber <shred@eratosthenes.starfleet.de>\n"
- "Updated in 2001-03 by Chris Young <chris@unsatisfactorysoftware.co.uk>\n"
- "Yet Another (tm) AmigaGuide to HTML Converter!\n\n"
- "USAGE:\tFILE/A\t\t\tAmigaGuide file to be converted\n"
- "\tTO/K\t\t\tDestination drawer for the html pages\n"
- "\tURL=HOMEURL/K\t\tURL accessed by the 'HOME' button\n"
- "\tFINDURL=SEARCHURL/K\tURL accessed by the 'SEARCH' button\n"
- "\tPREV/K\t\t\t'PREV' button text/image\n"
- "\tNEXT/K\t\t\t'NEXT' button text/image\n"
- "\tINDEX/K\t\t\t'INDEX' button text/image\n"
- "\tTOC/K\t\t\t'CONTENTS' button text/image\n"
- "\tHELP/K\t\t\t'HELP' button text/image\n"
- "\tRETRACE/K\t\t'RETRACE' button text/image (displays only if specified)\n"
- "\tHOME/K\t\t\t'HOME' button text/image\n"
- "\tFIND=SEARCH/K\t\t'SEARCH' button text/image\n"
- "\tBAR/K\t\t\tBar text between navigation buttons\n"
- "\tBODY/K\t\t\tAddition to the body tag of every page\n"
- "\tVER=VERBATIM/S\t\tList of created files\n"
- "\tIMG=IMAGES/S\t\tCreate image navigation bar\n"
- "\tFTR=FOOTER/S\t\tNavigation bar also at end of page\n"
- "\tNL=NOLINKS/S\t\tIgnore internet links\n"
- "\tNE=NOEMAIL/S\t\tIgnore e-mail addresses\n"
- "\tNW=NOWARN/S\t\tDon't show warnings\n"
- "\tMSDOS/S\t\t\tCreate MS-DOS filenames (*.htm)\n"
- "\tNONAVBAR/S\t\tDo not create the HTML navigation bar\n"
- "\tNOMOZNAV/S\t\tDo not create Mozilla-compatible Site Navigation Bar\n"
- "\tSHOWALL/S\t\tKeep navbar consistent between pages\n"
- "\tHTMLHEAD/K\t\tHTML to put in front of guide text\n"
- "\tHTMLHEADF/K\t\tFile containing HTMLHEAD (overrides HTMLHEAD)\n"
- "\tHTMLFOOT/K\t\tHTML to put underneath guide text\n"
- "\tHTMLFOOTF/K\t\tFile containing HTMLFOOT (overrides HTMLFOOT)\n"
- "\tCSS/K\t\t\tURL of Cascading Style Sheet to link to\n"
- "\tWORDWRAP/S\t\tWord-wraps text (converts @wordwrap)\n"
- "\tSMARTWRAP/S\t\tSmartwraps text (converts @smartwrap)\n"
- "\tVARWIDTH/S\t\tDo not use fixed width font (#?WRAP only)\n"
- "\tNOAUTO/S\t\tDo not auto-detect wrap mode\n"
-
- "\n");
- return(0);
- }
- //<
-
- /**************************************************************/
-
- /* New GuiML stuff starts here.. code might be a bit messy *
- * as it is largely cut'n'paste from a different project *
- * --- Starts with GuideML 3.1 --- */
-
- void wbmain(struct WBStartup *WBenchMsg)
- {
- struct WBArg *wbarg;
- char i;
- int olddir;
- int name = 0;
-
- wb=1;
- ok=1;
-
- param.prev = "< Browse";
- param.next = "Browse >";
- param.index = "Index";
- param.toc = "Contents";
- param.home = "Home";
- param.help = "Help";
- param.find = "Search";
- param.bar = defbar;
- param.retrace = NULL;
-
- if((intuitionbase = OpenLibrary("intuition.library",37))==0)
- {
- err("Unable to open intuition.library v37","OK",20);
- }
-
- if((DOSBase = OpenLibrary("dos.library",37))==0)
- {
- err("Unable to open dos.library v37","OK",20);
- }
-
- if((aslbase = OpenLibrary("asl.library",38))==0)
- {
- err("Unable to open asl.library v38","OK",20);
- }
- if((GadToolsBase = OpenLibrary("gadtools.library",37))==0)
- {
- err("Unable to open gadtools.library v37","OK",20);
- }
-
- if((WindowBase = OpenLibrary("window.class",44))==0) err("Unable to open window.class v44","OK",20);
- if((LayoutBase = OpenLibrary("gadgets/layout.gadget",44))==0) err("Unable to open layout.gadget v44","OK",20);
- if((ButtonBase = OpenLibrary("gadgets/button.gadget",44))==0) err("Unable to open button.gadget v44","OK",20);
- if((CheckBoxBase = OpenLibrary("gadgets/checkbox.gadget",44))==0) err("Unable to open checkbox.gadget v44","OK",20);
- if((LabelBase = OpenLibrary("images/label.image",44))==0) err("Unable to open label.image v44","OK",20);
- if((ChooserBase = OpenLibrary("gadgets/chooser.gadget",44))==0) err("Unable to open chooser.gadget v44","OK",20);
- if((ClickTabBase = OpenLibrary("gadgets/clicktab.gadget",44))==0) err("Unable to open clicktab.gadget v44","OK",20);
- // if((IntegerBase = OpenLibrary("gadgets/integer.gadget",44))==0) err("Unable to open integer.gadget v44","OK",20);
- // if((ListBrowserBase = OpenLibrary("gadgets/listbrowser.gadget",44))==0) err("Unable to open listbrowser.gadget v44","OK",20);
- if((GetFileBase = OpenLibrary("gadgets/getfile.gadget",44))==0) err("Unable to open getfile.gadget v44","OK",20);
- if((StringBase = OpenLibrary("gadgets/string.gadget",44))==0) err("Unable to open string.gadget v44","OK",20);
-
-
- IconBase = OpenLibrary("icon.library",44);
- if(!IconBase) err("Cannot open icon.library v44","OK",20);
-
- for(i=0,wbarg=WBenchMsg->sm_ArgList;i<WBenchMsg->sm_NumArgs;i++,wbarg++)
- {
- olddir =-1;
- if((wbarg->wa_Lock)&&(*wbarg->wa_Name))
- olddir = CurrentDir(wbarg->wa_Lock);
- if(!name)
- {
- strcpy(defname,"PROGDIR:");
- AddPart(defname,wbarg->wa_Name,100);
- name=1;
- }
-
- gettooltypes(wbarg);
-
- if(olddir !=-1) CurrentDir(olddir);
- }
-
- ui();
-
- }
-
- void gettooltypes(struct WBArg *wbarg)
- {
- struct DiskObject *dobj;
- CONST_STRPTR *toolarray;
- char *s;
-
-
- if((*wbarg->wa_Name) && (dobj=GetIconTags(wbarg->wa_Name,NULL)))
- {
- toolarray = (CONST_STRPTR *)dobj->do_ToolTypes;
- if(s = (char *)FindToolType(toolarray,"FILE"))
- {
- ttfrom = AllocMem(strlen(s)+1,NULL);
- if(ttfrom)
- {
- strcpy(ttfrom,s);
- param.from = ttfrom;
- }
- }
- if(s = (char *)FindToolType(toolarray,"TO"))
- {
- ttto = AllocMem(strlen(s)+1,NULL);
- if(ttto)
- {
- strcpy(ttto,s);
- param.to = ttto;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"HOMEURL"))
- {
- tthomeurl = AllocMem(strlen(s)+1,NULL);
- if(tthomeurl)
- {
- strcpy(tthomeurl,s);
- param.homeurl = tthomeurl;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"SEARCHURL"))
- {
- ttfindurl = AllocMem(strlen(s)+1,NULL);
- if(ttfindurl)
- {
- strcpy(ttfindurl,s);
- param.findurl = ttfindurl;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"PREV"))
- {
- ttprev = AllocMem(strlen(s)+1,NULL);
- if(ttprev)
- {
- strcpy(ttprev,s);
- param.prev = ttprev;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"NEXT"))
- {
- ttnext = AllocMem(strlen(s)+1,NULL);
- if(ttnext)
- {
- strcpy(ttnext,s);
- param.next = ttnext;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"INDEX"))
- {
- ttindex = AllocMem(strlen(s)+1,NULL);
- if(ttindex)
- {
- strcpy(ttindex,s);
- param.index = ttindex;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"TOC"))
- {
- tttoc = AllocMem(strlen(s)+1,NULL);
- if(tttoc)
- {
- strcpy(tttoc,s);
- param.toc = tttoc;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"HELP"))
- {
- tthelp = AllocMem(strlen(s)+1,NULL);
- if(tthelp)
- {
- strcpy(tthelp,s);
- param.help = tthelp;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"RETRACE"))
- {
- ttretrace = AllocMem(strlen(s)+1,NULL);
- if(ttretrace)
- {
- strcpy(ttretrace,s);
- param.retrace = ttretrace;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"HOME"))
- {
- tthome = AllocMem(strlen(s)+1,NULL);
- if(tthome)
- {
- strcpy(tthome,s);
- param.home = tthome;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"SEARCH"))
- {
- ttfind = AllocMem(strlen(s)+1,NULL);
- if(ttfind)
- {
- strcpy(ttfind,s);
- param.find = ttfind;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"BAR"))
- {
- ttbar = AllocMem(strlen(s)+1,NULL);
- if(ttbar)
- {
- strcpy(ttbar,s);
- param.bar = ttbar;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"BODY"))
- {
- ttbody = AllocMem(strlen(s)+1,NULL);
- if(ttbody)
- {
- strcpy(ttbody,s);
- param.bodyext = ttbody;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"HTMLHEADF"))
- {
- tthtmlheadf = AllocMem(strlen(s)+1,NULL);
- if(tthtmlheadf)
- {
- strcpy(tthtmlheadf,s);
- param.htmlheadf = tthtmlheadf;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"HTMLFOOTF"))
- {
- tthtmlfootf = AllocMem(strlen(s)+1,NULL);
- if(tthtmlfootf)
- {
- strcpy(tthtmlfootf,s);
- param.htmlfootf = tthtmlfootf;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"CSS"))
- {
- ttcss = AllocMem(strlen(s)+1,NULL);
- if(ttcss)
- {
- strcpy(ttcss,s);
- param.cssurl = ttcss;
- }
- }
-
- if(s = (char *)FindToolType(toolarray,"IMAGES")) param.images = TRUE;
- if(s = (char *)FindToolType(toolarray,"FOOTER")) param.footer = TRUE;
- if(s = (char *)FindToolType(toolarray,"NOLINKS")) param.nolink = TRUE;
- if(s = (char *)FindToolType(toolarray,"NOEMAIL")) param.noemail = TRUE;
- if(s = (char *)FindToolType(toolarray,"MSDOS")) param.msdos = TRUE;
- if(s = (char *)FindToolType(toolarray,"NONAVBAR")) param.nonavbar = TRUE;
- if(s = (char *)FindToolType(toolarray,"NOMOZNAV")) param.nomoznav = TRUE;
- if(s = (char *)FindToolType(toolarray,"SHOWALL")) param.showall = TRUE;
- if(s = (char *)FindToolType(toolarray,"VARWIDTH")) param.varwidth = TRUE;
- if(s = (char *)FindToolType(toolarray,"NOAUTO")) param.noauto = TRUE;
- if(s = (char *)FindToolType(toolarray,"WORDWRAP")) param.wordwrap = TRUE;
- if(s = (char *)FindToolType(toolarray,"SMARTWRAP")) param.smartwrap = TRUE;
- FreeDiskObject(dobj);
- }
-
- }
-
- void savetooltypes(char *fname,int def)
- {
- struct DiskObject *dobj;
- UBYTE **oldtooltypes;
- UBYTE *olddefaulttool;
- UBYTE oldtype;
- long olddir=-1;
- UBYTE *newtooltypes[30];
- char tttmp1[100];
- char tttmp2[100];
- char tttmp3[100];
- char tttmp4[100];
- char tttmp5[100];
- char tttmp6[100];
- char tttmp7[100];
- char tttmp8[100];
- char tttmp9[100];
- char tttmp10[100];
- char tttmp11[100];
- char tttmp12[100];
- char tttmp13[100];
- char tttmp14[100];
- char tttmp15[100];
- char tttmp16[100];
- char tttmp17[100];
- char defaulttool[] = "guideml\0";
-
- //char *fname="progdir:guideml\0";
-
- // if((wbarg->wa_Lock) && (wbarg->wa_Name)) olddir=CurrentDir(wbarg->wa_Lock);
-
- // if((*wbarg->wa_Name) && (dobj=GetDiskObject(wbarg->wa_Name)))
- if(dobj=GetIconTags(fname,ICONGETA_FailIfUnavailable,FALSE,NULL))
- {
- oldtooltypes = dobj->do_ToolTypes;
- olddefaulttool = dobj->do_DefaultTool;
- oldtype = dobj->do_Type;
-
- if(param.smartwrap) newtooltypes[0] = "SMARTWRAP";
- else newtooltypes[0] = "(SMARTWRAP)";
- if(param.wordwrap) newtooltypes[1] = "WORDWRAP";
- else newtooltypes[1] = "(WORDWRAP)";
- if(param.noauto) newtooltypes[2] = "NOAUTO";
- else newtooltypes[2] = "(NOAUTO)";
- if(param.varwidth) newtooltypes[3] = "VARWIDTH";
- else newtooltypes[3] = "(VARWIDTH)";
- if(param.showall) newtooltypes[4] = "SHOWALL";
- else newtooltypes[4] = "(SHOWALL)";
- if(param.nomoznav) newtooltypes[5] = "NOMOZNAV";
- else newtooltypes[5] = "(NOMOZNAV)";
- if(param.nonavbar) newtooltypes[6] = "NONAVBAR";
- else newtooltypes[6] = "(NONAVBAR)";
- if(param.msdos) newtooltypes[7] = "MSDOS";
- else newtooltypes[7] = "(MSDOS)";
- if(param.noemail) newtooltypes[8] = "NOEMAIL";
- else newtooltypes[8] = "(NOEMAIL)";
- if(param.nolink) newtooltypes[9] = "NOLINKS";
- else newtooltypes[9] = "(NOLINKS)";
- if(param.footer) newtooltypes[10] = "FOOTER";
- else newtooltypes[10] = "(FOOTER)";
- if(param.images) newtooltypes[11] = "IMAGES";
- else newtooltypes[11] = "(IMAGES)";
- if(param.cssurl)
- {
- strcpy(tttmp1,"CSS=");
- newtooltypes[12] = strcat(tttmp1,param.cssurl);
- }
- else
- {
- newtooltypes[12]="(CSS=)";
- }
-
- if(param.htmlfootf)
- {
- strcpy(tttmp2,"HTMLFOOTF=");
- newtooltypes[13] = strcat(tttmp2,param.htmlfootf);
- }
- else
- {
- newtooltypes[13]="(HTMLFOOTF=)";
- }
-
- if(param.htmlheadf)
- {
- strcpy(tttmp3,"HTMLHEADF=");
- newtooltypes[14] = strcat(tttmp3,param.htmlheadf);
- }
- else
- {
- newtooltypes[14]="(HTMLHEADF=)";
- }
-
- if(param.bodyext)
- {
- strcpy(tttmp4,"BODY=");
- newtooltypes[15] = strcat(tttmp4,param.bodyext);
- }
- else
- {
- newtooltypes[15]="(BODY=)";
- }
-
- if(param.bar)
- {
- strcpy(tttmp5,"BAR=");
- newtooltypes[16] = strcat(tttmp5,param.bar);
- }
- else
- {
- newtooltypes[16]="(BAR=)";
- }
-
- if(param.find)
- {
- strcpy(tttmp6,"SEARCH=");
- newtooltypes[17] = strcat(tttmp6,param.find);
- }
- else
- {
- newtooltypes[17]="(SEARCH=)";
- }
-
- if(param.home)
- {
- strcpy(tttmp7,"HOME=");
- newtooltypes[18] = strcat(tttmp7,param.home);
- }
- else
- {
- newtooltypes[18]="(HOME=)";
- }
-
- if(param.retrace)
- {
- strcpy(tttmp8,"RETRACE=");
- newtooltypes[19] = strcat(tttmp8,param.retrace);
- }
- else
- {
- newtooltypes[19]="(RETRACE=)";
- }
-
- if(param.help)
- {
- strcpy(tttmp9,"HELP=");
- newtooltypes[20] = strcat(tttmp9,param.help);
- }
- else
- {
- newtooltypes[20]="(HELP=)";
- }
-
- if(param.toc)
- {
- strcpy(tttmp10,"TOC=");
- newtooltypes[21] = strcat(tttmp10,param.toc);
- }
- else
- {
- newtooltypes[21]="(TOC=)";
- }
-
- if(param.index)
- {
- strcpy(tttmp11,"INDEX=");
- newtooltypes[22] = strcat(tttmp11,param.index);
- }
- else
- {
- newtooltypes[22]="(INDEX=)";
- }
-
- if(param.next)
- {
- strcpy(tttmp12,"NEXT=");
- newtooltypes[23] = strcat(tttmp12,param.next);
- }
- else
- {
- newtooltypes[23]="(NEXT=)";
- }
-
- if(param.prev)
- {
- strcpy(tttmp13,"PREV=");
- newtooltypes[24] = strcat(tttmp13,param.prev);
- }
- else
- {
- newtooltypes[24]="(PREV=)";
- }
-
- if(param.findurl)
- {
- strcpy(tttmp14,"SEARCHURL=");
- newtooltypes[25] = strcat(tttmp14,param.findurl);
- }
- else
- {
- newtooltypes[25]="(SEARCHURL=)";
- }
-
- if(param.homeurl)
- {
- strcpy(tttmp15,"HOMEURL=");
- newtooltypes[26] = strcat(tttmp15,param.homeurl);
- }
- else
- {
- newtooltypes[26]="(HOMEURL=)";
- }
-
- if(!def)
- {
-
- if(param.to)
- {
- strcpy(tttmp16,"TO=");
- newtooltypes[27] = strcat(tttmp16,param.to);
- }
- else
- {
- newtooltypes[27]="(TO=)";
- }
-
- if(param.from)
- {
- strcpy(tttmp17,"FILE=");
- newtooltypes[28] = strcat(tttmp17,param.from);
- }
- else
- {
- newtooltypes[28]="(FILE=)";
- }
-
- dobj->do_DefaultTool = defaulttool;
- dobj->do_Type = WBPROJECT;
-
- }
- else
- {
- newtooltypes[27]=NULL;
- }
-
- newtooltypes[29] = NULL;
- dobj->do_ToolTypes = newtooltypes;
- PutIconTags(fname,dobj,NULL); // PutDiskObject(fname,dobj); // PutDiskObject(wbarg->wa_Name,dobj);
- dobj->do_ToolTypes=oldtooltypes;
- dobj->do_DefaultTool=olddefaulttool;
- dobj->do_Type = oldtype;
- FreeDiskObject(dobj);
- }
-
- // if(olddir!=-1) CurrentDir(olddir);
-
- }
-
- int saveas()
- {
- BPTR fp;
- int t;
- char *filename[2048];
- char guidemlcmd[2048];
- struct FileRequester *req;
- struct TagItem asltags[] = {ASLFR_TitleText,(ULONG)"Save As...",
- ASLFR_InitialShowVolumes,TRUE,
- ASLFR_DoSaveMode,TRUE,TAG_DONE};
-
- req = (struct FileRequester *)AllocAslRequest(ASL_FileRequest,NULL);
- t = AslRequest(req,asltags);
-
- if (t==FALSE)
- {
- // user cancelled
- return(0);
- }
-
- strcpy((STRPTR)filename,req->fr_Drawer);
- AddPart((STRPTR)filename,req->fr_File,2048);
-
- FreeAslRequest(req);
-
- fp = Open((STRPTR)filename,MODE_NEWFILE);
-
- strcpy(guidemlcmd,"guideml \"");
- if(param.from) strcat(guidemlcmd,param.from);
- if(param.from) strcat(guidemlcmd,"\" ");
- if(param.to) strcat(guidemlcmd,"TO=\"");
- if(param.to) strcat(guidemlcmd,param.to);
- if(param.to) strcat(guidemlcmd,"\" ");
- if(param.homeurl) strcat(guidemlcmd,"HOMEURL=\"");
- if(param.homeurl) strcat(guidemlcmd,param.homeurl);
- if(param.homeurl) strcat(guidemlcmd,"\" ");
- if(param.prev) strcat(guidemlcmd,"PREV=\"");
- if(param.prev) strcat(guidemlcmd,param.prev);
- if(param.prev) strcat(guidemlcmd,"\" ");
- if(param.next) strcat(guidemlcmd,"NEXT=\"");
- if(param.next) strcat(guidemlcmd,param.next);
- if(param.next) strcat(guidemlcmd,"\" ");
- if(param.index) strcat(guidemlcmd,"INDEX=\"");
- if(param.index) strcat(guidemlcmd,param.index);
- if(param.index) strcat(guidemlcmd,"\" ");
- if(param.toc) strcat(guidemlcmd,"TOC=\"");
- if(param.toc) strcat(guidemlcmd,param.toc);
- if(param.toc) strcat(guidemlcmd,"\" ");
- if(param.help) strcat(guidemlcmd,"HELP=\"");
- if(param.help) strcat(guidemlcmd,param.help);
- if(param.help) strcat(guidemlcmd,"\" ");
- if(param.retrace) strcat(guidemlcmd,"RETRACE=\"");
- if(param.retrace) strcat(guidemlcmd,param.retrace);
- if(param.retrace) strcat(guidemlcmd,"\" ");
- if(param.home) strcat(guidemlcmd,"HOME=\"");
- if(param.home) strcat(guidemlcmd,param.home);
- if(param.home) strcat(guidemlcmd,"\" ");
- if(param.bar) strcat(guidemlcmd,"BAR=\"");
- if(param.bar) strcat(guidemlcmd,param.bar);
- if(param.bar) strcat(guidemlcmd,"\" ");
- if(param.bodyext) strcat(guidemlcmd,"BODY=\"");
- if(param.bodyext) strcat(guidemlcmd,param.bodyext);
- if(param.bodyext) strcat(guidemlcmd,"\" ");
- if(param.htmlheadf) strcat(guidemlcmd,"HTMLHEADF=\"");
- if(param.htmlheadf) strcat(guidemlcmd,param.htmlheadf);
- if(param.htmlheadf) strcat(guidemlcmd,"\" ");
- if(param.htmlfootf) strcat(guidemlcmd,"HTMLFOOTF=\"");
- if(param.htmlfootf) strcat(guidemlcmd,param.htmlfootf);
- if(param.htmlfootf) strcat(guidemlcmd,"\" ");
- if(param.cssurl) strcat(guidemlcmd,"CSS=\"");
- if(param.cssurl) strcat(guidemlcmd,param.cssurl);
- if(param.cssurl) strcat(guidemlcmd,"\" ");
-
- if(param.images) strcat(guidemlcmd,"IMAGES ");
- if(param.footer) strcat(guidemlcmd,"FOOTER ");
- if(param.nolink) strcat(guidemlcmd,"NOLINKS ");
- if(param.noemail) strcat(guidemlcmd,"NOEMAIL ");
- if(param.msdos) strcat(guidemlcmd,"MSDOS ");
- if(param.nonavbar) strcat(guidemlcmd,"NONAVBAR ");
- if(param.nomoznav) strcat(guidemlcmd,"NOMOZNAV ");
- if(param.showall) strcat(guidemlcmd,"SHOWALL ");
- if(param.wordwrap) strcat(guidemlcmd,"WORDWRAP ");
- if(param.smartwrap) strcat(guidemlcmd,"SMARTWRAP ");
- if(param.varwidth) strcat(guidemlcmd,"VARWIDTH ");
- if(param.noauto) strcat(guidemlcmd,"NOAUTO ");
- strcat(guidemlcmd,"\n");
-
-
- FPuts(fp,guidemlcmd);
-
- Close(fp);
-
- savetooltypes((STRPTR)filename,0);
- }
-
-
- void ui()
- {
- long i=0; // temp variable
- struct List optlist;
- struct List navoptlist;
- struct List imgoptlist;
- struct List linkoptlist;
- struct List tablist;
- struct MsgPort *AppPort;
-
- struct Window *windows[WID_LAST];
- Object *objects[OID_LAST];
-
- UBYTE *opts[] = {"Auto","Wordwrap","Smartwrap","None",NULL};
- UBYTE *navopts[] = {"Header","Both","None",NULL};
- UBYTE *linkopts[] = {"Convert All","Not Email","Email Only","None",NULL};
- UBYTE *imgopts[] = {"Text","Images",NULL};
- UBYTE *tabs[] = {"Convert","Options",NULL};
- struct Menu *menustrip;
- UWORD menunum,itemnum,subnum; //menusel;
- struct MenuItem *item;
- int wrapm =0;
- int navm=0;
- int linkm=0;
-
- if(param.noauto) wrapm = 3;
- if(param.wordwrap) wrapm = 1;
- if(param.smartwrap) wrapm = 2;
- if(!param.noauto) wrapm = 0;
-
- if(param.footer) navm = 1;
- if(param.nonavbar) navm=2;
-
- if(param.noemail) linkm=1;
- if(param.nolink) linkm=linkm+2;
-
- make_list(&optlist,opts);
- make_list(&navoptlist,navopts);
- make_list(&imgoptlist,imgopts);
- make_list(&linkoptlist,linkopts);
- maketablist(&tablist,tabs);
-
- if ( AppPort = CreateMsgPort() )
- {
- /* Create the window object.
- */
- objects[OID_MAIN] = WindowObject,
- WA_ScreenTitle, "GuideML " VERSIONSTR " (" VERSIONDATE ")",
- WA_Title, "GuideML",
- WA_Activate, TRUE,
- WA_DepthGadget, TRUE,
- WA_DragBar, TRUE,
- WA_CloseGadget, TRUE,
- WA_SizeGadget, TRUE,
- WA_SmartRefresh,TRUE,
- WA_IDCMP,IDCMP_MENUPICK,
- WINDOW_IconifyGadget, FALSE,
- WINDOW_IconTitle, "GuideML",
- WINDOW_AppPort, AppPort,
- WINDOW_Position, WPOS_CENTERMOUSE,
- WINDOW_ParentGroup, gadgets[GID_MAIN] = VGroupObject,
- LAYOUT_SpaceOuter, TRUE,
- LAYOUT_AddChild, gadgets[GID_TABS] = ClickTabObject,
- GA_ID, GID_TABS,
- GA_RelVerify, TRUE,
- CLICKTAB_Labels,&tablist,
- CLICKTAB_PageGroup, PageObject,
- PAGE_Add,LayoutObject,
- LAYOUT_AddChild,VGroupObject,
- LAYOUT_SpaceOuter,TRUE,
- LAYOUT_AddChild, gadgets[GID_FILE] = GetFileObject,
- GA_ID, GID_FILE,
- GA_RelVerify, TRUE,
- GETFILE_TitleText,"GuideML",
- GETFILE_Pattern,"#?.guide",
- GETFILE_DoPatterns,TRUE,
- GETFILE_ReadOnly,FALSE,
- GETFILE_FullFile,param.from,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Input File",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_TO] = GetFileObject,
- GA_ID, GID_TO,
- GA_RelVerify, TRUE,
- GETFILE_TitleText,"GuideML",
- GETFILE_DoSaveMode,TRUE,
- GETFILE_DrawersOnly,TRUE,
- GETFILE_ReadOnly,FALSE,
- GETFILE_Drawer,param.to,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Output Path",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_HOMEURL] = StringObject,
- GA_ID, GID_HOMEURL,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.homeurl,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Home URL",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_FINDURL] = StringObject,
- GA_ID, GID_FINDURL,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.findurl,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Search URL",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_CSS] = StringObject,
- GA_ID, GID_CSS,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.cssurl,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "CSS _URL",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_BODY] = StringObject,
- GA_ID, GID_BODY,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.bodyext,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Body",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_HTMLHEADF] = GetFileObject,
- GA_ID, GID_HTMLHEADF,
- GA_RelVerify, TRUE,
- GETFILE_TitleText,"GuideML",
- GETFILE_Pattern,"#?.(s|%)htm(l|%)",
- GETFILE_DoPatterns,TRUE,
- GETFILE_ReadOnly,FALSE,
- GETFILE_FullFile,param.htmlheadf,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "HTML H_eader",
- LabelEnd,
- LAYOUT_AddChild, gadgets[GID_HTMLFOOTF] = GetFileObject,
- GA_ID, GID_HTMLFOOTF,
- GA_RelVerify, TRUE,
- GETFILE_TitleText,"GuideML",
- GETFILE_Pattern,"#?.(s|%)htm(l|%)",
- GETFILE_DoPatterns,TRUE,
- GETFILE_ReadOnly,FALSE,
- GETFILE_FullFile,param.htmlfootf,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "HTML _Footer",
- LabelEnd,
- LayoutEnd,
- LayoutEnd,
- // PageEnd,
-
- // CLICKTAB_PageGroup, PageObject,
- PAGE_Add,LayoutObject,
- LAYOUT_AddChild,VGroupObject,
- // wrap
- LAYOUT_AddChild,HGroupObject,
- LAYOUT_AddChild,VGroupObject,
- LAYOUT_SpaceOuter,TRUE,
- LAYOUT_AddChild, gadgets[GID_WRAP] = ChooserObject,
- GA_ID, GID_WRAP,
- GA_RelVerify, TRUE,
- CHOOSER_PopUp,TRUE,
- CHOOSER_Labels,&optlist,
- CHOOSER_Selected,wrapm,
- CHOOSER_AutoFit,TRUE,
- ChooserEnd,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Wrap mode",
- LabelEnd,
- CHILD_NominalSize, TRUE,
-
- LAYOUT_AddChild, gadgets[GID_NAVBAR] = ChooserObject,
- GA_ID, GID_NAVBAR,
- GA_RelVerify, TRUE,
- CHOOSER_PopUp,TRUE,
- CHOOSER_Labels,&navoptlist,
- CHOOSER_Selected,navm,
- CHOOSER_AutoFit,TRUE,
- ChooserEnd,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Nav bar",
- LabelEnd,
- CHILD_NominalSize, TRUE,
-
- LAYOUT_AddChild, gadgets[GID_IMAGES] = ChooserObject,
- GA_ID, GID_IMAGES,
- GA_RelVerify, TRUE,
- CHOOSER_PopUp,TRUE,
- CHOOSER_Labels,&imgoptlist,
- CHOOSER_Selected,param.images,
- CHOOSER_AutoFit,TRUE,
- ChooserEnd,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Style",
- LabelEnd,
- CHILD_NominalSize, TRUE,
-
- LAYOUT_AddChild, gadgets[GID_LINKS] = ChooserObject,
- GA_ID, GID_LINKS,
- GA_RelVerify, TRUE,
- CHOOSER_PopUp,TRUE,
- CHOOSER_Labels,&linkoptlist,
- CHOOSER_Selected,linkm,
- CHOOSER_AutoFit,TRUE,
- ChooserEnd,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Links",
- LabelEnd,
- CHILD_NominalSize, TRUE,
-
- LAYOUT_AddChild, gadgets[GID_PREV] = StringObject,
- GA_ID, GID_PREV,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.prev,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Previous",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_NEXT] = StringObject,
- GA_ID, GID_NEXT,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.next,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "Nex_t",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_INDEX] = StringObject,
- GA_ID, GID_INDEX,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.index,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "Inde_x",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_TOC] = StringObject,
- GA_ID, GID_TOC,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.toc,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "C_ontents",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LayoutEnd,
- LAYOUT_AddChild,VGroupObject,
- LAYOUT_AddChild, gadgets[GID_VARWIDTH] = CheckBoxObject,
- GA_ID, GID_VARWIDTH,
- GA_RelVerify, TRUE,
- GA_Text,"_Variable Width Font",
- GA_Selected,param.varwidth,
- CHECKBOX_TextPlace,PLACETEXT_LEFT,
- CheckBoxEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_MOZNAV] = CheckBoxObject,
- GA_ID, GID_MOZNAV,
- GA_RelVerify, TRUE,
- GA_Text,"_Mozilla Site Navigation Bar",
- GA_Selected,param.nomoznav+1,
- CHECKBOX_TextPlace,PLACETEXT_LEFT,
- CheckBoxEnd,
- /*CHILD_Label, LabelObject,
- LABEL_Text, "_Site Nav",
- LabelEnd,*/
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_SHOWALL] = CheckBoxObject,
- GA_ID, GID_SHOWALL,
- GA_RelVerify, TRUE,
- GA_Text,"Consistent _Across Pages",
- GA_Selected,param.showall,
- CHECKBOX_TextPlace,PLACETEXT_LEFT,
- CheckBoxEnd,
- /*CHILD_Label, LabelObject,
- LABEL_Text, "Show _All",
- LabelEnd,*/
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_MSDOS] = CheckBoxObject,
- GA_ID, GID_MSDOS,
- GA_RelVerify, TRUE,
- GA_Text,"MS-_DOS Compatible Filenames",
- GA_Selected,param.msdos,
- CHECKBOX_TextPlace,PLACETEXT_LEFT,
- CheckBoxEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_HELP] = StringObject,
- GA_ID, GID_HELP,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.help,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "H_elp",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_RETRACE] = StringObject,
- GA_ID, GID_RETRACE,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.retrace,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Retrace",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_HOME] = StringObject,
- GA_ID, GID_HOME,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.home,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "H_ome",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_FIND] = StringObject,
- GA_ID, GID_FIND,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.find,
- STRINGA_MaxChars,100,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "S_earch",
- LabelEnd,
- CHILD_NominalSize, TRUE,
- LAYOUT_AddChild, gadgets[GID_BAR] = StringObject,
- GA_ID, GID_BAR,
- GA_RelVerify, TRUE,
- STRINGA_TextVal,param.bar,
- STRINGA_MaxChars,10,
- End,
- CHILD_Label, LabelObject,
- LABEL_Text, "_Bar",
- LabelEnd,
- CHILD_NominalSize, TRUE,
-
- LayoutEnd,
- LayoutEnd,
- LayoutEnd,
- LayoutEnd,
- PageEnd,
-
- ClickTabEnd,
-
- LAYOUT_AddChild, HGroupObject,
- GA_BackFill, NULL,
- LAYOUT_SpaceOuter, FALSE,
- LAYOUT_VertAlignment, LALIGN_CENTER,
- LAYOUT_HorizAlignment, LALIGN_CENTER,
- // LAYOUT_BevelStyle, BVS_FIELD,
- LAYOUT_AddChild, gadgets[GID_CONV] = ButtonObject,
- GA_ID, GID_CONV,
- GA_RelVerify, TRUE,
- GA_Text,"_Convert",
- ButtonEnd,
- LayoutEnd,
- CHILD_WeightedHeight, 0,
- EndGroup,
- EndWindow;
-
-
- /* Object creation sucessful?
- */
- if (objects[OID_MAIN])
- {
- /* Open the window.
- */
- if (windows[WID_MAIN] = (struct Window *) RA_OpenWindow(objects[OID_MAIN]))
- {
- ULONG wait, signal, app = (1L << AppPort->mp_SigBit);
- ULONG done = FALSE;
- ULONG result;
- UWORD code;
-
- menustrip = addmenu(windows[WID_MAIN]);
-
- /* Obtain the window wait signal mask.
- */
- GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
-
- /* Input Event Loop
- */
- while (!done)
- {
- wait = Wait( signal | SIGBREAKF_CTRL_C | app );
-
- if(wait & SIGBREAKF_CTRL_C)
- {
- done = TRUE;
- }
- else
- {
- while ( (result = RA_HandleInput(objects[OID_MAIN], &code) ) != WMHI_LASTMSG )
- {
- switch (result & WMHI_CLASSMASK)
- {
- case WMHI_CLOSEWINDOW:
- windows[WID_MAIN] = NULL;
- done = TRUE;
- break;
-
- case WMHI_MENUPICK:
- while (code !=MENUNULL)
- {
- //menusel = code;
- item = ItemAddress(menustrip,code);
- menunum = MENUNUM(code);
- itemnum = ITEMNUM(code);
- subnum = SUBNUM(code);
-
- switch(menunum)
- {
- case 0: // Project
- switch(itemnum)
- {
-
- case 0: // save
- SetWindowPointer(windows[WID_MAIN],WA_BusyPointer,TRUE,WA_PointerDelay,TRUE,TAG_DONE);
- saveas();
- SetWindowPointer(windows[WID_MAIN],TAG_DONE);
- break;
-
- case 2: // about
-
- err("GuideML "VERSIONSTR"\n\n© 1997-8 Richard Körber\nhttp://www.shredzone.de\n\n© 2001-4 Chris Young\nhttp://www.unsatisfactorysoftware.co.uk","OK",0);
- break;
-
- case 4: // quit
-
- windows[WID_MAIN] = NULL;
- done = TRUE;
-
- break;
-
- }
- break;
-
- case 1: // Settings
- switch(itemnum)
- {
- case 0:
- // save defaults
- SetWindowPointer(windows[WID_MAIN],WA_BusyPointer,TRUE,WA_PointerDelay,TRUE,TAG_DONE);
- savetooltypes(defname,1);
- SetWindowPointer(windows[WID_MAIN],TAG_DONE);
- break;
- }
- break;
-
-
- }
-
-
- code = item->NextSelect;
- }
- break;
-
- case WMHI_GADGETUP:
- switch (result & WMHI_GADGETMASK)
- {
- case GID_FILE:
- if(DoMethod((Object *)gadgets[GID_FILE],GFILE_REQUEST,windows[WID_MAIN]))
- {
- GetAttr(GETFILE_FullFile,gadgets[GID_FILE],(ULONG*)¶m.from);
- }
-
- break;
-
- case GID_TO:
- if(DoMethod((Object *)gadgets[GID_TO],GFILE_REQUEST,windows[WID_MAIN]))
- {
- GetAttr(GETFILE_Drawer,gadgets[GID_TO],(ULONG*)¶m.to);
- }
-
- break;
- case GID_HTMLHEADF:
- if(DoMethod((Object *)gadgets[GID_HTMLHEADF],GFILE_REQUEST,windows[WID_MAIN]))
- {
- GetAttr(GETFILE_FullFile,gadgets[GID_HTMLHEADF],(ULONG*)¶m.htmlheadf);
- }
- if(param.htmlheadf)
- {
- if(strlen(param.htmlheadf)==0) param.htmlheadf=0;
- }
-
- break;
- case GID_HTMLFOOTF:
- if(DoMethod((Object *)gadgets[GID_HTMLFOOTF],GFILE_REQUEST,windows[WID_MAIN]))
- {
- GetAttr(GETFILE_FullFile,gadgets[GID_HTMLFOOTF],(ULONG*)¶m.htmlfootf);
- }
- if(param.htmlfootf)
- {
- if(strlen(param.htmlfootf)==0) param.htmlfootf=0;
- }
- break;
-
- case GID_BODY:
- GetAttr(STRINGA_TextVal,gadgets[GID_BODY],(ULONG*)¶m.bodyext);
- if(strlen(param.bodyext)==0) param.bodyext=0;
- break;
- case GID_CSS:
- GetAttr(STRINGA_TextVal,gadgets[GID_CSS],(ULONG*)¶m.cssurl);
- if(strlen(param.cssurl)==0) param.cssurl=0;
- break;
- case GID_HOMEURL:
- GetAttr(STRINGA_TextVal,gadgets[GID_HOMEURL],(ULONG*)¶m.homeurl);
- if(strlen(param.homeurl)==0) param.homeurl=0;
- break;
-
- case GID_FINDURL:
- GetAttr(STRINGA_TextVal,gadgets[GID_FINDURL],(ULONG*)¶m.findurl);
- if(strlen(param.findurl)==0) param.findurl=0;
- break;
-
- case GID_RETRACE:
- GetAttr(STRINGA_TextVal,gadgets[GID_RETRACE],(ULONG*)¶m.retrace);
- if(strlen(param.retrace)==0) param.retrace=0;
- break;
-
- case GID_PREV:
- GetAttr(STRINGA_TextVal,gadgets[GID_PREV],(ULONG*)¶m.prev);
- if(strlen(param.prev)==0) param.prev=0;
- break;
-
- case GID_NEXT:
- GetAttr(STRINGA_TextVal,gadgets[GID_NEXT],(ULONG*)¶m.next);
- if(strlen(param.next)==0) param.next=0;
- break;
-
- case GID_INDEX:
- GetAttr(STRINGA_TextVal,gadgets[GID_INDEX],(ULONG*)¶m.index);
- if(strlen(param.index)==0) param.index=0;
- break;
-
- case GID_TOC:
- GetAttr(STRINGA_TextVal,gadgets[GID_TOC],(ULONG*)¶m.toc);
- if(strlen(param.toc)==0) param.toc=0;
- break;
-
- case GID_HELP:
- GetAttr(STRINGA_TextVal,gadgets[GID_HELP],(ULONG*)¶m.help);
- if(strlen(param.help)==0) param.help=0;
- break;
-
- case GID_FIND:
- GetAttr(STRINGA_TextVal,gadgets[GID_FIND],(ULONG*)¶m.find);
- if(strlen(param.find)==0) param.find=0;
- break;
-
- case GID_HOME:
- GetAttr(STRINGA_TextVal,gadgets[GID_HOME],(ULONG*)¶m.home);
- if(strlen(param.home)==0) param.home=0;
- break;
-
- case GID_BAR:
- GetAttr(STRINGA_TextVal,gadgets[GID_BAR],(ULONG*)¶m.bar);
- break;
-
- case GID_CONV:
- if(!param.from)
- {
- err("You must select an AmigaGuide\ndocument to convert!","OK",0);
- }
- else
- {
- SetWindowPointer(windows[WID_MAIN],WA_BusyPointer,TRUE,TAG_DONE);
- main();
- param.prev = textlabs.prev;
- param.next = textlabs.next;
- param.index = textlabs.index;
- param.toc = textlabs.toc;
- param.home = textlabs.home;
- param.help = textlabs.help;
- param.find = textlabs.find;
- param.retrace = textlabs.retrace;
- param.bar = textlabs.bar;
- SetWindowPointer(windows[WID_MAIN],TAG_DONE);
- }
- break;
-
- case GID_WRAP:
-
- switch(code)
- {
- case 0:
- param.noauto=0;
- param.wordwrap=0;
- param.smartwrap=0;
- SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,FALSE,TAG_DONE);
- RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
- break;
-
- case 1:
- param.wordwrap=TRUE;
- param.smartwrap=FALSE;
- param.noauto=TRUE;
- SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,FALSE,TAG_DONE);
- RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
- break;
-
- case 2:
- param.wordwrap=FALSE;
- param.smartwrap=TRUE;
- param.noauto=TRUE;
- SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,FALSE,TAG_DONE);
- RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
- break;
-
- case 3:
- param.wordwrap=FALSE;
- param.smartwrap=FALSE;
- param.noauto=TRUE;
- SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,TRUE,TAG_DONE);
- RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
- break;
-
- }
-
- break;
-
- case GID_VARWIDTH:
- param.varwidth=code;
- break;
-
- case GID_NAVBAR:
-
- switch(code)
- {
- case 0:
- param.nonavbar=FALSE;
- param.footer=FALSE;
- SetAttrs(gadgets[GID_IMAGES],GA_Disabled,FALSE,TAG_DONE);
- RethinkLayout(gadgets[GID_IMAGES],windows[WID_MAIN],NULL,TRUE);
- break;
-
- case 1:
- param.nonavbar=FALSE;
- param.footer=TRUE;
- SetAttrs(gadgets[GID_IMAGES],GA_Disabled,FALSE,TAG_DONE);
- RethinkLayout(gadgets[GID_IMAGES],windows[WID_MAIN],NULL,TRUE);
- break;
-
- case 2:
- param.nonavbar=TRUE;
- param.footer=FALSE;
- SetAttrs(gadgets[GID_IMAGES],GA_Disabled,TRUE,TAG_DONE);
- RethinkLayout(gadgets[GID_IMAGES],windows[WID_MAIN],NULL,TRUE);
- break;
- }
-
- break;
-
- case GID_LINKS:
-
- switch(code)
- {
- case 0:
- param.noemail=FALSE;
- param.nolink=FALSE;
- break;
-
- case 1:
- param.noemail=TRUE;
- param.nolink=FALSE;
- break;
-
- case 2:
- param.noemail=FALSE;
- param.nolink=TRUE;
- break;
-
- case 3:
- param.noemail=TRUE;
- param.nolink=TRUE;
- break;
- }
- break;
-
- case GID_IMAGES:
- param.images=code;
- break;
-
- case GID_MOZNAV:
- param.nomoznav=code+1;
- break;
-
- case GID_SHOWALL:
- param.showall=code;
- break;
-
- case GID_MSDOS:
- param.msdos=code;
- break;
-
- }
- break;
-
- case WMHI_ICONIFY:
- RA_Iconify(objects[OID_MAIN]);
- windows[WID_MAIN] = NULL;
- break;
-
- case WMHI_UNICONIFY:
- windows[WID_MAIN] = (struct Window *) RA_OpenWindow(objects[OID_MAIN]);
-
- if (windows[WID_MAIN])
- {
- GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
- }
- else
- {
- done = TRUE; // error re-opening window!
- }
- break;
- }
- }
- }
- }
- }
-
- /* Disposing of the window object will also close the window if it is
- * already opened, and it will dispose of the layout object attached to it.
- */
- DisposeObject(objects[OID_MAIN]);
- }
-
- DeleteMsgPort(AppPort);
- }
- free_list(&optlist);
- freetablist(&tablist);
- FreeMenus(menustrip); // menu
- cleanup(0);
-
- /*
- closelibs();
-
- return(0);
- */
- }
-
-
- void free_list(struct List *list)
- {
- struct Node *node,*nextnode;
- node = list ->lh_Head;
- while (nextnode = node->ln_Succ)
- {
- FreeChooserNode(node);
- node=nextnode;
- }
- NewList(list);
- }
-
- void freetablist(struct List *list)
- {
- struct Node *node,*nextnode;
- node = list ->lh_Head;
- while (nextnode = node->ln_Succ)
- {
- FreeClickTabNode(node);
- node=nextnode;
- }
- NewList(list);
- }
-
- BOOL make_list(struct List *list, UBYTE **labels1)
- {
- struct Node *node;
- WORD i = 0;
- int ro=FALSE;
-
- NewList(list);
-
- while (*labels1)
- {
-
- if (node = AllocChooserNode(
- CNA_Text, *labels1,
- CNA_ReadOnly, ro,
- TAG_DONE))
- {
- AddTail(list, node);
- }
- else
- break;
-
- labels1++;
- i++;
- ro=FALSE;
- }
- return(TRUE);
- }
-
- BOOL maketablist(struct List *list, UBYTE **labels1)
- {
- struct Node *node;
- WORD i = 0;
-
- NewList(list);
-
- while (*labels1)
- {
-
- if (node = AllocClickTabNode(
- TNA_Text, *labels1,
- TNA_Number, i,
- TAG_DONE))
- {
- AddTail(list, node);
- }
- else
- break;
-
- labels1++;
- i++;
- }
- return(TRUE);
- }
-
- struct Menu *addmenu(struct Window *win)
- {
-
-
- APTR vi;
- struct Menu *menustrip;
- struct NewMenu menu[] = {
- {NM_TITLE,"Project" , 0 ,0,0,0,},
- { NM_ITEM,"Save As..." ,"S",0,0,0,},
- { NM_ITEM,NM_BARLABEL , 0 ,0,0,0,},
- { NM_ITEM,"About..." ,"A",0,0,0,},
- { NM_ITEM,NM_BARLABEL , 0 ,0,0,0,},
- { NM_ITEM,"Quit" ,"Q",0,0,0,},
- {NM_TITLE,"Settings" , 0 ,0,0,0,},
- { NM_ITEM,"Save As Defaults" ,"D",0,0,0,},
- { NM_END,0,0,0,0,0,},
- };
-
- menustrip = CreateMenus(menu,GTMN_FullMenu,TRUE,TAG_DONE);
- vi = GetVisualInfoA(win->WScreen,TAG_DONE);
- LayoutMenus(menustrip,vi,GTMN_NewLookMenus,TRUE,TAG_DONE);
- // SetAttrs(win,WINDOW_MenuStrip,menustrip,TAG_DONE);
- SetMenuStrip(win,menustrip);
-
- return(menustrip);
- }
-
- int err(char *errtxt,char *gadgtxt,int fail)
- {
- int rc;
-
- if(intuitionbase)
- {
- struct EasyStruct errorreq =
- {
- sizeof(struct EasyStruct),
- 0,
- "GuideML",
- errtxt,
- gadgtxt
- };
- rc = EasyRequest(NULL,&errorreq,NULL);
- }
- else
- {
- printf("%s\n",*errtxt);
- }
- if (fail) cleanup(fail);
-
- return(rc);
- }
-
- void cleanup(int fail)
- {
- if(ttfrom) FreeMem(ttfrom,strlen(ttfrom)+1);
- if(ttto) FreeMem(ttto,strlen(ttto)+1);
- if(tthomeurl) FreeMem(tthomeurl,strlen(tthomeurl)+1);
- if(ttfindurl) FreeMem(ttfindurl,strlen(ttfindurl)+1);
- if(ttprev) FreeMem(ttprev,strlen(ttprev)+1);
- if(ttnext) FreeMem(ttnext,strlen(ttnext)+1);
- if(ttindex) FreeMem(ttindex,strlen(ttindex)+1);
- if(tttoc) FreeMem(tttoc,strlen(tttoc)+1);
- if(tthelp) FreeMem(tthelp,strlen(tthelp)+1);
- if(ttretrace) FreeMem(ttretrace,strlen(ttretrace)+1);
- if(tthome) FreeMem(tthome,strlen(tthome)+1);
- if(ttfind) FreeMem(ttfind,strlen(ttfind)+1);
- if(ttbar) FreeMem(ttbar,strlen(ttbar)+1);
- if(ttbody) FreeMem(ttbody,strlen(ttbody)+1);
- if(tthtmlheadf) FreeMem(tthtmlheadf,strlen(tthtmlheadf)+1);
- if(tthtmlfootf) FreeMem(tthtmlfootf,strlen(tthtmlfootf)+1);
- if(ttcss) FreeMem(ttcss,strlen(ttcss)+1);
-
- if(WindowBase) CloseLibrary(WindowBase);
- if(LayoutBase) CloseLibrary(LayoutBase);
- if(ButtonBase) CloseLibrary(ButtonBase);
- if(CheckBoxBase) CloseLibrary(CheckBoxBase);
- if(LabelBase) CloseLibrary(LabelBase);
- if(ChooserBase) CloseLibrary(ChooserBase);
- if(ClickTabBase) CloseLibrary(ClickTabBase);
- // if(IntegerBase) CloseLibrary(IntegerBase);
- // if(ListBrowserBase) CloseLibrary(ListBrowserBase);
- if(GetFileBase) CloseLibrary(GetFileBase);
- if(StringBase) CloseLibrary(StringBase);
- if(GadToolsBase) CloseLibrary(GadToolsBase);
- if(IconBase) CloseLibrary(IconBase);
-
- if(aslbase) CloseLibrary(aslbase);
- if(DOSBase) CloseLibrary(DOSBase);
- if(intuitionbase) CloseLibrary(intuitionbase);
-
-
- exit(fail);
- }
-